1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // Copyright (C) 2011 Vicente J. Botet Escriba 11 // 12 // Distributed under the Boost Software License, Version 1.0. (See accompanying 13 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 14 15 // <boost/thread/future.hpp> 16 17 // class promise<R> 18 19 // promise(allocator_arg_t, const Allocator& a); 20 21 #define BOOST_THREAD_VERSION 3 22 23 #include <boost/thread/future.hpp> 24 #include <boost/detail/lightweight_test.hpp> 25 #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS 26 #include "../test_allocator.hpp" 27 main()28int main() 29 { 30 BOOST_TEST(test_alloc_base::count == 0); 31 { 32 boost::promise<int> p(boost::allocator_arg, test_allocator<int>()); 33 BOOST_TEST(test_alloc_base::count == 1); 34 boost::future<int> f = BOOST_THREAD_MAKE_RV_REF(p.get_future()); 35 BOOST_TEST(test_alloc_base::count == 1); 36 BOOST_TEST(f.valid()); 37 } 38 BOOST_TEST(test_alloc_base::count == 0); 39 { 40 boost::promise<int&> p(boost::allocator_arg, test_allocator<int>()); 41 BOOST_TEST(test_alloc_base::count == 1); 42 boost::future<int&> f = BOOST_THREAD_MAKE_RV_REF(p.get_future()); 43 BOOST_TEST(test_alloc_base::count == 1); 44 BOOST_TEST(f.valid()); 45 } 46 BOOST_TEST(test_alloc_base::count == 0); 47 { 48 boost::promise<void> p(boost::allocator_arg, test_allocator<void>()); 49 BOOST_TEST(test_alloc_base::count == 1); 50 boost::future<void> f = BOOST_THREAD_MAKE_RV_REF(p.get_future()); 51 BOOST_TEST(test_alloc_base::count == 1); 52 BOOST_TEST(f.valid()); 53 } 54 BOOST_TEST(test_alloc_base::count == 0); 55 56 57 return boost::report_errors(); 58 } 59 60 #else main()61int main() 62 { 63 return boost::report_errors(); 64 } 65 #endif 66 67 68