1 | // Copyright 2020 Peter Dimov |
2 | // Distributed under the Boost Software License, Version 1.0. |
3 | // https://www.boost.org/LICENSE_1_0.txt) |
4 | |
5 | #include <boost/bind/bind.hpp> |
6 | #include <boost/core/lightweight_test.hpp> |
7 | #include <boost/config.hpp> |
8 | #include <boost/config/workaround.hpp> |
9 | #include <functional> |
10 | |
11 | // |
12 | |
13 | int main() |
14 | { |
15 | BOOST_TEST_EQ( boost::bind( std::plus<int>(), 1, 2 )(), 3 ); |
16 | BOOST_TEST_EQ( boost::bind( std::minus<int>(), 1, 2 )(), -1 ); |
17 | BOOST_TEST_EQ( boost::bind( std::multiplies<int>(), 1, 2 )(), 2 ); |
18 | BOOST_TEST_EQ( boost::bind( std::divides<int>(), 1, 2 )(), 0 ); |
19 | BOOST_TEST_EQ( boost::bind( std::modulus<int>(), 1, 2 )(), 1 ); |
20 | BOOST_TEST_EQ( boost::bind( std::negate<int>(), 1 )(), -1 ); |
21 | |
22 | BOOST_TEST_EQ( boost::bind( std::equal_to<int>(), 1, 2 )(), false ); |
23 | BOOST_TEST_EQ( boost::bind( std::not_equal_to<int>(), 1, 2 )(), true ); |
24 | BOOST_TEST_EQ( boost::bind( std::greater<int>(), 1, 2 )(), false ); |
25 | BOOST_TEST_EQ( boost::bind( std::less<int>(), 1, 2 )(), true ); |
26 | BOOST_TEST_EQ( boost::bind( std::greater_equal<int>(), 1, 2 )(), false ); |
27 | BOOST_TEST_EQ( boost::bind( std::less_equal<int>(), 1, 2 )(), true ); |
28 | |
29 | BOOST_TEST_EQ( boost::bind( std::logical_and<int>(), 1, 2 )(), true ); |
30 | BOOST_TEST_EQ( boost::bind( std::logical_or<int>(), 1, 2 )(), true ); |
31 | BOOST_TEST_EQ( boost::bind( std::logical_not<int>(), 1 )(), false ); |
32 | |
33 | #if !BOOST_WORKAROUND(BOOST_MSVC, < 1600) |
34 | |
35 | BOOST_TEST_EQ( boost::bind( std::bit_and<int>(), 1, 2 )(), 0 ); |
36 | BOOST_TEST_EQ( boost::bind( std::bit_or<int>(), 1, 2 )(), 3 ); |
37 | BOOST_TEST_EQ( boost::bind( std::bit_xor<int>(), 1, 2 )(), 3 ); |
38 | |
39 | #endif |
40 | |
41 | return boost::report_errors(); |
42 | } |
43 | |