/*============================================================================= Copyright (c) 2001-2003 Joel de Guzman Use, modification and distribution is subject to 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) ==============================================================================*/ #include #include #include #include #include #include #include #include #include #include namespace boost { BOOST_UNARY_RESULT_OF(-x, result_of_negate); BOOST_UNARY_RESULT_OF(+x, result_of_posit); BOOST_UNARY_RESULT_OF(!x, result_of_logical_not); BOOST_UNARY_RESULT_OF(~x, result_of_invert); BOOST_UNARY_RESULT_OF(&x, result_of_reference); BOOST_UNARY_RESULT_OF(*x, result_of_dereference); BOOST_UNARY_RESULT_OF(++x, result_of_pre_increment); BOOST_UNARY_RESULT_OF(--x, result_of_pre_decrement); BOOST_UNARY_RESULT_OF(x++, result_of_post_increment); BOOST_UNARY_RESULT_OF(x--, result_of_post_decrement); BOOST_BINARY_RESULT_OF(x = y, result_of_assign); BOOST_ASYMMETRIC_BINARY_RESULT_OF(x[y], result_of_index); BOOST_BINARY_RESULT_OF(x += y, result_of_plus_assign); BOOST_BINARY_RESULT_OF(x -= y, result_of_minus_assign); BOOST_BINARY_RESULT_OF(x *= y, result_of_multiplies_assign); BOOST_BINARY_RESULT_OF(x /= y, result_of_divides_assign); BOOST_BINARY_RESULT_OF(x %= y, result_of_modulus_assign); BOOST_BINARY_RESULT_OF(x &= y, result_of_and_assign); BOOST_BINARY_RESULT_OF(x |= y, result_of_or_assign); BOOST_BINARY_RESULT_OF(x ^= y, result_of_xor_assign); BOOST_BINARY_RESULT_OF(x <<= y, result_of_shift_left_assign); BOOST_BINARY_RESULT_OF(x >>= y, result_of_shift_right_assign); BOOST_BINARY_RESULT_OF(x + y, result_of_plus); BOOST_BINARY_RESULT_OF(x - y, result_of_minus); BOOST_BINARY_RESULT_OF(x * y, result_of_multiplies); BOOST_BINARY_RESULT_OF(x / y, result_of_divides); BOOST_BINARY_RESULT_OF(x % y, result_of_modulus); BOOST_BINARY_RESULT_OF(x & y, result_of_and); BOOST_BINARY_RESULT_OF(x | y, result_of_or); BOOST_BINARY_RESULT_OF(x ^ y, result_of_xor); BOOST_BINARY_RESULT_OF(x << y, result_of_shift_left); BOOST_BINARY_RESULT_OF(x >> y, result_of_shift_right); BOOST_BINARY_RESULT_OF(x == y, result_of_equal_to); BOOST_BINARY_RESULT_OF(x != y, result_of_not_equal_to); BOOST_BINARY_RESULT_OF(x < y, result_of_less); BOOST_BINARY_RESULT_OF(x <= y, result_of_less_equal); BOOST_BINARY_RESULT_OF(x > y, result_of_greater); BOOST_BINARY_RESULT_OF(x >= y, result_of_greater_equal); BOOST_BINARY_RESULT_OF(x && y, result_of_logical_and); BOOST_BINARY_RESULT_OF(x || y, result_of_logical_or); BOOST_BINARY_RESULT_OF(true ? x : y, result_of_if_else); } using namespace boost; using namespace std; struct X {}; X operator+(X, int); struct Y {}; Y* operator+(Y, int); struct Z {}; Z const* operator+(Z const&, int); Z& operator+(Z&, int); bool operator==(Z, Z); bool operator==(Z, int); struct W {}; Z operator+(W, int); bool operator==(W, Z); int test_main(int, char*[]) { // PLUS { typedef result_of_plus::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_plus::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_plus::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_plus::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_plus::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_plus::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_plus::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_plus::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_plus::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_plus::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_plus::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_plus, double>::type result; BOOST_STATIC_ASSERT((is_same >::value)); } { typedef result_of_plus >::type result; BOOST_STATIC_ASSERT((is_same >::value)); } { typedef result_of_plus::type result; BOOST_STATIC_ASSERT((is_same::value)); } // INDEX { typedef result_of_index::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_index::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_index::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_index::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_index::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_index, int>::type result; BOOST_STATIC_ASSERT((is_same::reference>::value)); } { typedef result_of_index const, int>::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_index const, int>::type result; BOOST_STATIC_ASSERT((is_same::const_reference>::value)); } { typedef result_of_index, int>::type result; BOOST_STATIC_ASSERT((is_same::reference>::value)); } { typedef result_of_index::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_index::iterator, int>::type result; BOOST_STATIC_ASSERT((is_same::iterator::reference>::value)); } { typedef result_of_index::const_iterator, int>::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_index::const_iterator, int>::type result; BOOST_STATIC_ASSERT((is_same::const_iterator::reference>::value)); } { typedef result_of_index, char>::type result; BOOST_STATIC_ASSERT((is_same::mapped_type>::value)); } // PLUS ASSIGN { typedef result_of_plus_assign::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_plus_assign::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_plus_assign, double>::type result; BOOST_STATIC_ASSERT((is_same&>::value)); } // SHIFT LEFT { typedef result_of_shift_left::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_shift_left::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_shift_left::type result; BOOST_STATIC_ASSERT((is_same::value)); } // EQUAL { typedef result_of_equal_to::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_equal_to::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_equal_to::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_equal_to::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_equal_to::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_equal_to::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_equal_to::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_equal_to::type result; BOOST_STATIC_ASSERT((is_same::value)); } // MINUS (pointers) { typedef result_of_minus::type result; BOOST_STATIC_ASSERT((is_same::value)); } // DEREFERENCE { typedef result_of_dereference::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_dereference::iterator>::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_dereference >::type result; BOOST_STATIC_ASSERT((is_same::value)); } // ADDRESS OF { typedef result_of_reference::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_reference::type result; BOOST_STATIC_ASSERT((is_same::value)); } // PRE INCREMENT { typedef result_of_pre_increment::type result; BOOST_STATIC_ASSERT((is_same::value)); } // POST INCREMENT { typedef result_of_post_increment::type result; BOOST_STATIC_ASSERT((is_same::value)); } // IF-ELSE-EXPRESSION ( c ? a : b ) { typedef result_of_if_else::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_if_else::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_if_else::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_if_else::type result; BOOST_STATIC_ASSERT((is_same::value)); } { typedef result_of_if_else::type result; BOOST_STATIC_ASSERT((is_same::value)); } // DEDUCTION FAILURE { typedef result_of_plus::type result; BOOST_STATIC_ASSERT((is_same::value)); } return 0; }