summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/thread/test/functional/invoke/invoke_int_0_pass.cpp
blob: fa1f675439a44b23418b3cfad7ff04b8b5a83d8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// Copyright (C) 2014 Vicente J. Botet Escriba
//
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

// <boost/thread/detail/invoke.hpp>

#include <boost/thread/detail/invoke.hpp>
#include <boost/detail/lightweight_test.hpp>

int f()
{
  return 1;
}

struct A_int_0
{
  A_int_0()
  {
  }
  int operator()()
  {
    return 4;
  }
  int operator()() const
  {
    return 5;
  }
};


int main()
{
  const A_int_0 ca;
  A_int_0 a;

#if defined BOOST_THREAD_PROVIDES_INVOKE
  BOOST_TEST_EQ(boost::detail::invoke(f), 1);
  BOOST_TEST_EQ(boost::detail::invoke(&f), 1);
  BOOST_TEST_EQ(boost::detail::invoke(A_int_0()), 4);
  BOOST_TEST_EQ(boost::detail::invoke(a), 4);
  BOOST_TEST_EQ(boost::detail::invoke(ca), 5);
#endif

  BOOST_TEST_EQ(boost::detail::invoke<int>(f), 1);
  BOOST_TEST_EQ(boost::detail::invoke<int>(&f), 1);
  BOOST_TEST_EQ(A_int_0()(), 4);
#if defined BOOST_THREAD_PROVIDES_INVOKE || ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  BOOST_TEST_EQ(boost::detail::invoke<int>(A_int_0()), 4);
#else
  //BOOST_TEST_EQ(boost::detail::invoke<int>(A_int_0()), 5);
#endif
  BOOST_TEST_EQ(a(), 4);
  BOOST_TEST_EQ(boost::detail::invoke<int>(a), 4);
  BOOST_TEST_EQ(ca(), 5);
  BOOST_TEST_EQ(boost::detail::invoke<int>(ca), 5);

  return boost::report_errors();
}