33#if defined (__HP_aCC) && _RWSTD_HP_aCC_MAJOR < 6
48# pragma warning (disable: 4099)
52# pragma warning (disable: 4700)
62#ifndef _RWSTD_EXPLICIT_INSTANTIATION
66# if !defined (_RWSTD_NO_NAMESPACE) && !defined (_RWSTD_NO_HONOR_STD) \
67 && (!defined (_COMPILER_VERSION) || _COMPILER_VERSION > 730) \
68 && (!defined (__EDG_VERSION__) || __EDG_VERSION__ > 244)
74# define TEST_CLASS_DEF(name, Tparam) \
75 template class std::name Tparam; \
76 void name (void *name)
77# define TEST_CLASS_DEF_2(name, Tparam1, Tparam2) \
78 template class std::name Tparam1, Tparam2; \
79 void name (void *name)
80# define TEST_CLASS_DEF_3(name, Tparam1, Tparam2, Tparam3) \
81 template class std::name Tparam1, Tparam2, Tparam3; \
82 void name (void *name)
88# define TEST_CLASS_DEF(name, Tparam) \
89 template class std::name Tparam; \
91# define TEST_CLASS_DEF_2(name, Tparam1, Tparam2) \
92 template class std::name Tparam1, Tparam2; \
94# define TEST_CLASS_DEF_3(name, Tparam1, Tparam2, Tparam3) \
95 template class std::name Tparam1, Tparam2, Tparam3; \
99# if defined __GNUG__ && __GNUG__ < 3 && __GNU_MINOR__ < 96
102# define TEST_FUNCTION_DEF(decl) \
103 _RWSTD_NAMESPACE (std) { \
106 typedef void unused_typedef
108# define TEST_FUNCTION_DEF(decl) template decl
115# if !defined (_RWSTD_NO_NAMESPACE) && !defined (_RWSTD_NO_HONOR_STD)
119# define TEST_CLASS_DEF(name, ignore) void name (void *name)
120# define TEST_CLASS_DEF_2(name, ign1, ign2) void name (void *name)
121# define TEST_CLASS_DEF_3(name, ign1, ign2, ign3) void name (void *name)
125# define TEST_CLASS_DEF(name, ignore) void foo (void *name)
126# define TEST_CLASS_DEF_2(name, ign1, ign2) void foo (void *name)
127# define TEST_CLASS_DEF_3(name, ign1, ign2, ign3) void foo (void *name)
131# define TEST_FUNCTION_DEF(ignore) void unused_typedef
160 std::unary_negate<std::negate<int> >
161 std::not1 (
const std::negate<int>&));
166 std::binary_negate<std::equal_to<int> >
167 std::not2 (
const std::equal_to<int>&));
172 std::binder1st<std::plus<int> >
173 std::bind1st (
const std::plus<int>&,
const int&));
178 std::binder2nd<std::plus<int> >
179 std::bind2nd (
const std::plus<int>&,
const int&));
187 rw_info (0, 0, __LINE__,
"[lib.base]");
190 std::unary_function<int, void>::argument_type *argument = (
int*)0;
191 std::unary_function<int, void>::result_type *
result = (
void*)0;
193 std::binary_function<int, char, void>::first_argument_type *
a1 = (
int*)0;
194 std::binary_function<int, char, void>::second_argument_type *
a2 = (
char*)0;
195 std::binary_function<int, char, void>::result_type *
res = (
void*)0;
205#define TEST_UNARY_OP(fun, op, x) do { \
206 rw_info (0, 0, __LINE__, "std::" #fun); \
207 N::fun f CTOR_ARG_LIST; \
209 const N::fun f_cpy1 (f); \
211 const N::fun f_cpy2 = f; \
213 const std::unary_function<N::fun::argument_type, \
214 N::fun::result_type> *pf = &f; \
215 _RWSTD_UNUSED (pf); \
217 typedef N::fun fun_t; \
218 N::fun::result_type (N::fun::*pfun) \
219 UNARY_OP_ARG_LIST (fun_t) const = &N::fun::operator(); \
220 _RWSTD_UNUSED (pfun); \
222 rw_assert (f.operator() (x) == (op x), 0, __LINE__, \
223 #fun "().operator()(%i) == %i, got %i", \
224 x, (op x), f.operator()(x)); \
226 rw_assert (f_cpy1.operator() (x) == (op x), 0, __LINE__, \
227 #fun "::" #fun "(const " #fun "&)"); \
228 rw_assert (f_cpy2.operator() (x) == (op x), 0, __LINE__, \
229 #fun "::operator=" #fun "(const " #fun "&)"); \
232#define TEST_BINARY_OP(fun, op, x, y) do { \
233 rw_info (0, 0, __LINE__, "std::" #fun); \
234 N::fun f CTOR_ARG_LIST; \
236 const N::fun f_cpy1 (f); \
238 const N::fun f_cpy2 = f; \
240 const std::binary_function<N::fun::first_argument_type, \
241 N::fun::second_argument_type, \
242 N::fun::result_type> *pf = &f; \
243 _RWSTD_UNUSED (pf); \
245 typedef N::fun fun_t; \
246 N::fun::result_type (N::fun::*pfun) \
247 BINARY_OP_ARG_LIST (fun_t) const = &N::fun::operator(); \
248 _RWSTD_UNUSED (pfun); \
249 rw_assert (f.operator() (x, y) == (x op y), 0, __LINE__, \
250 #fun "().operator()(%i, %i) == %i, got %i", \
251 x, y, (x op y), f.operator()(x, y)); \
253 rw_assert (f_cpy1.operator() (x, y) == (x op y), 0, __LINE__, \
254 #fun "::" #fun "(const " #fun "&)"); \
255 rw_assert (f_cpy2.operator() (x, y) == (x op y), 0, __LINE__, \
256 #fun "::operator=" #fun "(const " #fun "&)"); \
264#define UNARY_OP_ARG_LIST(fun) (const fun::argument_type&)
265#define BINARY_OP_ARG_LIST(fun) \
266 (const fun::first_argument_type&, const fun::second_argument_type&)
273test_arithmetic_operations ()
275 rw_info (0, 0, __LINE__,
"[lib.arithmetic.operations]");
323 rw_info (0, 0, __LINE__,
"[lib.comparisons]");
357test_logical_operations ()
359 rw_info (0, 0, __LINE__,
"[lib.logical.operations]");
378void is_explicit (
const std::unary_negate<std::logical_not<int> >&);
380void is_explicit (
const std::pointer_to_unary_function<int, int>&);
381void is_explicit (
const std::pointer_to_binary_function<int, int, int>&);
402 rw_info (0, 0, __LINE__,
"[lib.negators]");
410#define CTOR_ARG_LIST \
411 = std::unary_negate<std::logical_not<int> > (std::logical_not<int> ())
419#define CTOR_ARG_LIST = std::not1 (std::logical_not<char> ())
422 TEST_UNARY_OP (unary_negate<std::logical_not<char> >, !!,
'\0');
423 TEST_UNARY_OP (unary_negate<std::logical_not<char> >, !!,
'1');
427#define CTOR_ARG_LIST \
428 = std::binary_negate<std::equal_to<double> > (std::equal_to<double> ())
431 TEST_BINARY_OP (binary_negate<std::equal_to<double> >, !=, 0.0, 1.0);
432 TEST_BINARY_OP (binary_negate<std::equal_to<double> >, !=, 1.0, 2.0);
436#define CTOR_ARG_LIST \
437 = std::binary_negate<std::not_equal_to<int> > (std::not_equal_to<int> ())
439 TEST_BINARY_OP (binary_negate<std::not_equal_to<int> >, ==, 0, 1);
440 TEST_BINARY_OP (binary_negate<std::not_equal_to<int> >, ==, 1, 2);
444#define CTOR_ARG_LIST = std::not2 (std::equal_to<int> ())
457 rw_info (0, 0, __LINE__,
"[lib.binders]");
460 struct binder1st_derivative: std::binder1st<std::minus<int> > {
462 binder1st_derivative ()
469 "binder1st<>::operator()");
473 "binder1st<>::value");
474 rw_assert (7 ==
operator()(0), 0, __LINE__,
475 "binder1st<>::operator()");
482 struct binder2nd_derivative: std::binder2nd<std::minus<int> > {
483 binder2nd_derivative ()
490 "binder2nd<>::operator()");
494 "binder2nd<>::value");
495 rw_assert (-7 ==
operator()(0), 0, __LINE__,
496 "binder2nd<>::operator()");
504#if defined __GNUG__ && __GNUG__ < 3 && __GNU_MINOR__ < 96
507 std::minus<int> obj_minus;
510# define CTOR_ARG_LIST (obj_minus, 1)
512# define CTOR_ARG_LIST (std::minus<int>(), 1)
525#define CTOR_ARG_LIST = std::bind1st (std::divides<int>(), 6)
533#define CTOR_ARG_LIST = std::bind2nd (std::plus<int>(), -2)
548test_function_pointer_adaptors ()
550 rw_info (0, 0, __LINE__,
"[lib.function.pointer.adaptors]");
558#define CTOR_ARG_LIST (&::square)
561#undef UNARY_OP_ARG_LIST
562#define UNARY_OP_ARG_LIST(fun) (fun::argument_type)
564#define pointer_to_unary_function_int pointer_to_unary_function<int, int>
571#define CTOR_ARG_LIST = std::ptr_fun (&::square)
578#define CTOR_ARG_LIST (&::shift)
581#undef BINARY_OP_ARG_LIST
582#define BINARY_OP_ARG_LIST(fun) \
583 (fun::first_argument_type, fun::second_argument_type)
585#define pointer_to_binary_function_int pointer_to_binary_function<int, int, int>
592#define CTOR_ARG_LIST = std::ptr_fun (&::shift)
605 operator int ()
const {
return i_; }
636test_member_pointer_adaptors ()
638 rw_info (0, 0, __LINE__,
"[lib.member.pointer.adaptors]");
647#define CTOR_ARG_LIST (&Integer::square)
649#define mem_fun_t_Integer_int mem_fun_t<int, Integer>
657#define CTOR_ARG_LIST = std::mem_fun (&Integer::square)
666#define CTOR_ARG_LIST (&Integer::div)
668#define mem_fun1_t_int_Integer_short mem_fun1_t<int, Integer, short>
675#define CTOR_ARG_LIST = std::mem_fun (&Integer::div)
683#define CTOR_ARG_LIST (&Integer::square)
686#undef UNARY_OP_ARG_LIST
687#define UNARY_OP_ARG_LIST(fun) (fun::argument_type&)
689#define mem_fun_ref_t_Integer_int mem_fun_ref_t<int, Integer>
698#define CTOR_ARG_LIST = std::mem_fun_ref (&Integer::square)
704#define CTOR_ARG_LIST (&Integer::div)
707#undef BINARY_OP_ARG_LIST
708#define BINARY_OP_ARG_LIST(fun) \
709 (fun::first_argument_type&, fun::second_argument_type)
711#define mem_fun1_ref_t_int_Integer_short mem_fun1_ref_t<int, Integer, short>
719#define CTOR_ARG_LIST = std::mem_fun_ref (&Integer::div)
728#define CTOR_ARG_LIST (&Integer::const_square)
731#undef UNARY_OP_ARG_LIST
732#define UNARY_OP_ARG_LIST(fun) (fun::argument_type)
734#define const_mem_fun_t_Integer_int const_mem_fun_t<int, Integer>
739 const Integer &int_cref = int_obj;
745#define CTOR_ARG_LIST = std::mem_fun (&Integer::const_square)
754#define CTOR_ARG_LIST (&Integer::const_div)
757#undef BINARY_OP_ARG_LIST
758#define BINARY_OP_ARG_LIST(fun) \
759 (fun::first_argument_type, fun::second_argument_type)
761#define const_mem_fun1_t_int_Integer_short \
762 const_mem_fun1_t<int, Integer, short>
769#define CTOR_ARG_LIST = std::mem_fun (&Integer::const_div)
777#define CTOR_ARG_LIST (&Integer::const_square)
780#undef UNARY_OP_ARG_LIST
781#define UNARY_OP_ARG_LIST(fun) (const fun::argument_type&)
783#define const_mem_fun_ref_t_Integer_int const_mem_fun_ref_t<int, Integer>
792#define CTOR_ARG_LIST = std::mem_fun_ref (&Integer::const_square)
798#define CTOR_ARG_LIST (&Integer::const_div)
801#undef BINARY_OP_ARG_LIST
802#define BINARY_OP_ARG_LIST(fun) \
803 (const fun::first_argument_type&, fun::second_argument_type)
805#define const_mem_fun1_ref_t_int_Integer_short \
806 const_mem_fun1_ref_t<int, Integer, short>
814#define CTOR_ARG_LIST = std::mem_fun_ref (&Integer::const_div)
830 test_arithmetic_operations ();
836 test_logical_operations ();
845 test_function_pointer_adaptors ();
848 test_member_pointer_adaptors ();
855int main (
int argc,
char *argv[])
857 return rw_test (argc, argv, __FILE__,
858 "lib.std.function_objects",
#define TEST_CLASS_DEF_2(name, Tparam1, Tparam2)
#define pointer_to_unary_function_int
#define const_mem_fun1_ref_t_int_Integer_short
#define const_mem_fun_ref_t_Integer_int
#define mem_fun_ref_t_Integer_int
#define mem_fun1_t_int_Integer_short
#define TEST_CLASS_DEF(name, Tparam)
#define mem_fun1_ref_t_int_Integer_short
#define TEST_CLASS_DEF_3(name, Tparam1, Tparam2, Tparam3)
#define const_mem_fun_t_Integer_int
#define const_mem_fun1_t_int_Integer_short
void is_explicit(const std::unary_negate< std::logical_not< int > > &)
#define pointer_to_binary_function_int
#define mem_fun_t_Integer_int
#define TEST_FUNCTION_DEF(decl)
#define TEST_UNARY_OP(fun, op, x)
#define TEST_BINARY_OP(fun, op, x, y)
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
#define _RWSTD_UNUSED(arg)
_TEST_EXPORT int rw_test(int argc, char *argv[], const char *filename, const char *clause, const char *comment, int(*testfun)(int, char **), const char *optspec,...)
_TEST_EXPORT int rw_info(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_assert(int, const char *, int, const char *,...)
int const_div(short n) const
has_implicit_ctor_from_member(int(Integer::*)())
has_implicit_ctor_from_member(int(Integer::*)() const)
has_implicit_ctor_from_member(int(Integer::*)(short) const)
has_implicit_ctor_from_member(int(Integer::*)(short))
has_implicit_ctor(int(*)(int))
has_implicit_ctor(const std::equal_to< int > &)
has_implicit_ctor(int(*)(int, int))
has_implicit_ctor(const std::logical_not< int > &)