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) 2014 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/detail/invoker.hpp>
16 
17 #include <boost/thread/detail/invoker.hpp>
18 #include <boost/detail/lightweight_test.hpp>
19 
f()20 int f()
21 {
22   return 1;
23 }
24 
25 struct A_int_0
26 {
A_int_0A_int_027   A_int_0()
28   {
29   }
operator ()A_int_030   int operator()()
31   {
32     return 4;
33   }
operator ()A_int_034   int operator()() const
35   {
36     return 5;
37   }
38 };
39 
40 
main()41 int main()
42 {
43   const A_int_0 ca;
44   A_int_0 a;
45 
46 #if defined BOOST_THREAD_PROVIDES_INVOKE
47   BOOST_TEST_EQ(boost::detail::invoker<int(*)()>(f)(), 1);
48   BOOST_TEST_EQ(boost::detail::invoker<int(*)()>(&f)(), 1);
49   BOOST_TEST_EQ(boost::detail::invoker<A_int_0>(A_int_0())(), 4);
50   BOOST_TEST_EQ(boost::detail::invoker<A_int_0>(a)(), 4);
51   BOOST_TEST_EQ(boost::detail::invoker<const A_int_0>(ca)(), 5);
52 #endif
53 
54   //BOOST_TEST_EQ(boost::detail::invoker<int>(f), 1);
55   //BOOST_TEST_EQ(boost::detail::invoker<int>(&f), 1);
56   BOOST_TEST_EQ(A_int_0()(), 4);
57 #if defined BOOST_THREAD_PROVIDES_INVOKE || ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
58   //BOOST_TEST_EQ(boost::detail::invoker<int>(A_int_0()), 4);
59 #else
60   //BOOST_TEST_EQ(boost::detail::invoke<int>(A_int_0()), 5);
61 #endif
62   //BOOST_TEST_EQ(a(), 4);
63   //BOOST_TEST_EQ(boost::detail::invoke<int>(a), 4);
64   //BOOST_TEST_EQ(ca(), 5);
65   //BOOST_TEST_EQ(boost::detail::invoke<int>(ca), 5);
66 
67   return boost::report_errors();
68 }
69