diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp index 6c70db408..eb4eac65c 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp @@ -10,40 +10,99 @@ // // template -// class function -// : public unary_function // iff sizeof...(ArgTypes) == 1 and -// // ArgTypes contains T1 -// : public binary_function // iff sizeof...(ArgTypes) == 2 and -// // ArgTypes contains T1 and T2 -// { +// class function { // public: -// typedef R result_type; -// ... -// }; +// typedef R result_type; +// typedef T1 argument_type; // iff sizeof...(ArgTypes) == 1 and +// // the type in ArgTypes is T1 +// typedef T1 first_argument_type; // iff sizeof...(ArgTypes) == 2 and +// // ArgTypes contains T1 and T2 +// typedef T2 second_argument_type; // iff sizeof...(ArgTypes) == 2 and +// // ArgTypes contains T1 and T2 +// ... +// }; #include #include + +template +class has_argument_type +{ + typedef char yes; + typedef long no; + + template static yes check( typename C::argument_type * ); + template static no check(...); +public: + enum { value = sizeof(check(0)) == sizeof(yes) }; +}; + +template +class has_first_argument_type +{ + typedef char yes; + typedef long no; + + template static yes check( typename C::first_argument_type * ); + template static no check(...); +public: + enum { value = sizeof(check(0)) == sizeof(yes) }; +}; + + +template +class has_second_argument_type +{ + typedef char yes; + typedef long no; + + template static yes check( typename C::second_argument_type *); + template static no check(...); +public: + enum { value = sizeof(check(0)) == sizeof(yes) }; +}; + +template +void test_nullary_function () +{ + static_assert((std::is_same::value), "" ); + static_assert((!has_argument_type::value), "" ); + static_assert((!has_first_argument_type::value), "" ); + static_assert((!has_second_argument_type::value), "" ); +} + +template +void test_unary_function () +{ + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((!has_first_argument_type::value), "" ); + static_assert((!has_second_argument_type::value), "" ); +} + +template +void test_binary_function () +{ + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((!has_argument_type::value), "" ); +} + +template +void test_other_function () +{ + static_assert((std::is_same::value), "" ); + static_assert((!has_argument_type::value), "" ); + static_assert((!has_first_argument_type::value), "" ); + static_assert((!has_second_argument_type::value), "" ); +} + int main() { - static_assert((!std::is_base_of, - std::function >::value), ""); - static_assert((!std::is_base_of, - std::function >::value), ""); - static_assert(( std::is_same< std::function::result_type, - int>::value), ""); - - static_assert(( std::is_base_of, - std::function >::value), ""); - static_assert((!std::is_base_of, - std::function >::value), ""); - static_assert(( std::is_same< std::function::result_type, - double>::value), ""); - - static_assert((!std::is_base_of, - std::function >::value), ""); - static_assert(( std::is_base_of, - std::function >::value), ""); - static_assert(( std::is_same< std::function::result_type, - double>::value), ""); + test_nullary_function, int>(); + test_unary_function , double, int>(); + test_binary_function , double, int, char>(); + test_other_function , double>(); }