// (C) Copyright John Maddock 2005. // Use, modification and distribution are 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) #ifndef BOOST_TR1_VERIFY_FUNCTOR_HPP #define BOOST_TR1_VERIFY_FUNCTOR_HPP #include #include #include #include #include "verify_return.hpp" template void verify_nullary_functor(F f, R) { verify_return_type(f(), R()); } template void verify_unary_functor(F f, B) { #ifndef NO_INHERT_TEST BOOST_STATIC_ASSERT( (::boost::is_base_and_derived::value)); #endif typedef typename B::argument_type arg_type; typedef typename B::result_type result_type; typedef typename F::argument_type b_arg_type; typedef typename F::result_type b_result_type; BOOST_STATIC_ASSERT((::boost::is_same::value)); BOOST_STATIC_ASSERT((::boost::is_same::value)); static arg_type a; typedef typename boost::remove_reference::type result_value; verify_return_type(f(a), result_value()); } template void verify_field_functor(F f, B) { // same as verify_unary_functor, but no nested result_type // because it depends on the argument type. typedef typename B::argument_type arg_type; typedef typename B::result_type result_type; static arg_type a; typedef typename boost::remove_reference::type result_value; verify_return_type(f(a), result_value()); result_type r = f(a); (void)r; } template void verify_binary_functor(F f, B) { #ifndef NO_INHERT_TEST BOOST_STATIC_ASSERT( (::boost::is_base_and_derived::value)); #endif typedef typename B::first_argument_type b_arg1_type; typedef typename B::second_argument_type b_arg2_type; typedef typename B::result_type b_result_type; typedef typename F::first_argument_type arg1_type; typedef typename F::second_argument_type arg2_type; typedef typename F::result_type result_type; BOOST_STATIC_ASSERT((::boost::is_same::value)); BOOST_STATIC_ASSERT((::boost::is_same::value)); BOOST_STATIC_ASSERT((::boost::is_same::value)); static arg1_type a; static arg2_type b; verify_return_type(f(a, b), result_type()); } #endif