7#if defined (_STLP_USE_NAMESPACES)
24#if defined (STLPORT) && !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
57# if defined (__GNUC__) && defined (_STLP_USE_NAMESPACES)
60# define __true_type std::__true_type
61# define __false_type std::__false_type
70int const* int_const_pointer;
71int volatile* int_volatile_pointer;
72int const volatile* int_const_volatile_pointer;
74int const int_const_val = 0;
75int volatile int_volatile_val = 0;
76int & int_ref = int_val;
77int const& int_const_ref = int_val;
78int const volatile& int_const_volatile_ref = int_val;
85 any_type() : m_data(1) {}
86 any_type(
const any_type&) : m_data(2) {}
87 any_type& operator = (
const any_type&)
88 { m_data = 3;
return *
this; }
89 ~any_type() { m_data = 0; }
96any_type
const* any_const_pointer;
97any_type
volatile* any_volatile_pointer;
98any_type
const volatile* any_const_volatile_pointer;
104# if defined (_STLP_USE_BOOST_SUPPORT)
106BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(any_pod_type)
110any_pod_type* any_pod_pointer;
111any_pod_type
const* any_pod_const_pointer;
112any_pod_type
volatile* any_pod_volatile_pointer;
113any_pod_type
const volatile* any_pod_const_volatile_pointer;
115# if defined (_STLP_USE_NAMESPACES)
120 typedef __true_type has_trivial_default_constructor;
122 typedef __true_type has_trivial_assignment_operator;
126# if defined (_STLP_USE_NAMESPACES)
138template <
typename _Src,
typename _Dst>
139int is_convertible(_Src, _Dst) {
140# if !defined(__BORLANDC__)
146 return type_to_value(_Ret());
149template <
typename _Src,
typename _Dst>
150int is_cv_convertible(_Src, _Dst) {
151# if !defined(__BORLANDC__)
157 return type_to_value(_Ret());
251# if defined (__BORLANDC__)
252 typedef __selectT<__true_type, __true_type, __false_type>::_Ret _SelectFirstRet;
254 typedef __selectT<__false_type, __true_type, __false_type>::_Ret _SelectSecondRet;
284template <
typename _Type>
287 return type_to_value(_Ret());
296 typedef signed char signed_char;
298 typedef unsigned char unsigned_char;
300# if defined (_STLP_HAS_WCHAR_T)
304 typedef unsigned short unsigned_short;
307 typedef unsigned int unsigned_int;
310 typedef unsigned long unsigned_long;
312# if defined (_STLP_LONG_LONG)
320# if !defined ( _STLP_NO_LONG_DOUBLE )
321 typedef long double long_double;
330template <
typename _Type>
331int is_rational(_Type) {
333 return type_to_value(_Ret());
342 typedef signed char signed_char;
344 typedef unsigned char unsigned_char;
346# if defined (_STLP_HAS_WCHAR_T)
350 typedef unsigned short unsigned_short;
353 typedef unsigned int unsigned_int;
356 typedef unsigned long unsigned_long;
358# if defined (_STLP_LONG_LONG)
366# if !defined ( _STLP_NO_LONG_DOUBLE )
367 typedef long double long_double;
376template <
typename _Type>
377int is_pointer_type(_Type) {
389 CPPUNIT_ASSERT( is_pointer_type(int_const_volatile_pointer) == 1 );
399#if defined (STLPORT) && defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
412template <
typename _Tp1,
typename _Tp2>
413int are_both_pointer_type (_Tp1, _Tp2) {
421 CPPUNIT_CHECK( are_both_pointer_type(int_val, int_val) == 0 );
422 CPPUNIT_CHECK( are_both_pointer_type(int_pointer, int_pointer) == 1 );
423 CPPUNIT_CHECK( are_both_pointer_type(int_const_pointer, int_const_pointer) == 1 );
424 CPPUNIT_CHECK( are_both_pointer_type(int_volatile_pointer, int_volatile_pointer) == 1 );
425 CPPUNIT_CHECK( are_both_pointer_type(int_const_volatile_pointer, int_const_volatile_pointer) == 1 );
426 CPPUNIT_CHECK( are_both_pointer_type(int_ref, int_ref) == 0 );
427 CPPUNIT_CHECK( are_both_pointer_type(int_const_ref, int_const_ref) == 0 );
429 CPPUNIT_CHECK( are_both_pointer_type(any_pointer, any_pointer) == 1 );
434template <
typename _Tp1,
typename _Tp2>
435int is_ok_to_use_memcpy(_Tp1 val1, _Tp2 val2) {
442#if defined (STLPORT) && !defined (_STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS)
443 CPPUNIT_CHECK( is_ok_to_use_memcpy(int_pointer, int_pointer) == 1 );
444 CPPUNIT_CHECK( is_ok_to_use_memcpy(int_const_pointer, int_pointer) == 1 );
445 CPPUNIT_CHECK( is_ok_to_use_memcpy(int_pointer, int_volatile_pointer) == 0 );
446 CPPUNIT_CHECK( is_ok_to_use_memcpy(int_pointer, int_const_volatile_pointer) == 0 );
447 CPPUNIT_CHECK( is_ok_to_use_memcpy(int_const_pointer, int_const_pointer) == 0 );
448 CPPUNIT_CHECK( is_ok_to_use_memcpy(int_const_pointer, int_volatile_pointer) == 0 );
449 CPPUNIT_CHECK( is_ok_to_use_memcpy(int_const_pointer, int_const_volatile_pointer) == 0 );
450 CPPUNIT_CHECK( is_ok_to_use_memcpy(int_const_volatile_pointer, int_const_volatile_pointer) == 0 );
451 CPPUNIT_CHECK( is_ok_to_use_memcpy(int_pointer, any_pointer) == 0 );
452 CPPUNIT_CHECK( is_ok_to_use_memcpy(any_pointer, int_pointer) == 0 );
453 CPPUNIT_CHECK( is_ok_to_use_memcpy(any_pointer, any_pointer) == 0 );
454 CPPUNIT_CHECK( is_ok_to_use_memcpy(any_pointer, any_const_pointer) == 0 );
455 CPPUNIT_CHECK( is_ok_to_use_memcpy(any_pod_pointer, int_pointer) == 0 );
456 CPPUNIT_CHECK( is_ok_to_use_memcpy(any_pod_pointer, any_pod_pointer) == 1 );
457 CPPUNIT_CHECK( is_ok_to_use_memcpy(any_pod_pointer, any_pod_const_pointer) == 0 );
466template <
typename _Tp1,
typename _Tp2>
467int is_ok_to_use_memmove(_Tp1 val1, _Tp2 val2) {
474#if defined (STLPORT) && !defined (_STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS)
475 CPPUNIT_CHECK( is_ok_to_use_memmove(int_pointer, int_pointer) == 1 );
476 CPPUNIT_CHECK( is_ok_to_use_memmove(int_const_pointer, int_pointer) == 1 );
477 CPPUNIT_CHECK( is_ok_to_use_memmove(int_pointer, int_volatile_pointer) == 0 );
478 CPPUNIT_CHECK( is_ok_to_use_memmove(int_pointer, int_const_volatile_pointer) == 0 );
479 CPPUNIT_CHECK( is_ok_to_use_memmove(int_const_pointer, int_const_pointer) == 0 );
480 CPPUNIT_CHECK( is_ok_to_use_memmove(int_const_pointer, int_volatile_pointer) == 0 );
481 CPPUNIT_CHECK( is_ok_to_use_memmove(int_const_pointer, int_const_volatile_pointer) == 0 );
482 CPPUNIT_CHECK( is_ok_to_use_memmove(int_const_volatile_pointer, int_const_volatile_pointer) == 0 );
483 CPPUNIT_CHECK( is_ok_to_use_memmove(int_pointer, any_pointer) == 0 );
484 CPPUNIT_CHECK( is_ok_to_use_memmove(any_pointer, int_pointer) == 0 );
485 CPPUNIT_CHECK( is_ok_to_use_memmove(any_pointer, any_pointer) == 0 );
486 CPPUNIT_CHECK( is_ok_to_use_memmove(any_pointer, any_const_pointer) == 0 );
487 CPPUNIT_CHECK( is_ok_to_use_memmove(any_pod_pointer, int_pointer) == 0 );
488 CPPUNIT_CHECK( is_ok_to_use_memmove(any_pod_pointer, any_pod_pointer) == 1 );
489 CPPUNIT_CHECK( is_ok_to_use_memmove(any_pod_pointer, any_pod_const_pointer) == 0 );
494template <
typename _Tp>
495int has_trivial_destructor(_Tp) {
497 return type_to_value(_TrivialDestructor());
500struct DestructorMonitor
503 { ++nb_destructor_call; }
505 static size_t nb_destructor_call;
508size_t DestructorMonitor::nb_destructor_call = 0;
510# if defined (_STLP_USE_NAMESPACES)
515 typedef __true_type has_trivial_default_constructor;
517 typedef __true_type has_trivial_assignment_operator;
521# if defined (_STLP_USE_NAMESPACES)
530 CPPUNIT_CHECK( has_trivial_destructor(int_const_pointer) == 1 );
531 CPPUNIT_CHECK( has_trivial_destructor(int_volatile_pointer) == 1 );
532 CPPUNIT_CHECK( has_trivial_destructor(int_const_volatile_pointer) == 1 );
542 DestructorMonitor::nb_destructor_call = 0;
549template <
typename _Tp>
550int is_POD_type(_Tp) {
552 return type_to_value(_IsPODType());
562 CPPUNIT_CHECK( is_POD_type(int_const_volatile_pointer) == 1 );
572template <
typename _Tp>
573int is_stlport_class(_Tp) {
575# if !defined (__BORLANDC__)
576 typedef typename _STLportClass::_Ret _Is;
580 return type_to_value(_Is());
588# if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
CPPUNIT_TEST(ok_to_use_memmove)
CPPUNIT_TEST_SUITE(TypeTraitsTest)
void trivial_destructor()
CPPUNIT_TEST(pointer_type)
CPPUNIT_TEST(ok_to_use_memcpy)
CPPUNIT_TEST(both_pointer_type)
CPPUNIT_TEST(trivial_destructor)
CPPUNIT_TEST(stlport_class)
CPPUNIT_TEST(reference_type)
#define CPPUNIT_STOP_IGNORE
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
#define CPPUNIT_ASSERT(X)
#define _STLP_TEMPLATE_NULL
GLboolean GLboolean GLboolean b
static BOOL is_integer(parse_buffer *buf)
_OKToSwap< _Tp1, _Tp2, _IsRef1, _IsRef2 > _IsOKToSwap(_Tp1 *, _Tp2 *, const _IsRef1 &, const _IsRef2 &)
_TrivialUCopy< _Src, _Dst > _UseTrivialUCopy(_Src *, _Dst *)
_TrivialCopy< _Src, _Dst > _UseTrivialCopy(_Src *, _Dst *)