void TestIteratorTraits() {
    AssertSameType( static_cast<typename Iterator::difference_type*>(0), static_cast<ptrdiff_t*>(0) );
    AssertSameType( static_cast<typename Iterator::value_type*>(0), static_cast<T*>(0) );
    AssertSameType( static_cast<typename Iterator::pointer*>(0), static_cast<T**>(0) );
    AssertSameType( static_cast<typename Iterator::iterator_category*>(0), static_cast<std::random_access_iterator_tag*>(0) );
    T x;
    typename Iterator::reference xr = x;
    typename Iterator::pointer xp = &x;
    ASSERT( &xr==xp, NULL );
}
void TestTypes() {
    AssertSameType( static_cast<MyTable::key_type*>(0), static_cast<MyKey*>(0) );
    AssertSameType( static_cast<MyTable::mapped_type*>(0), static_cast<MyData*>(0) );
    AssertSameType( static_cast<MyTable::value_type*>(0), static_cast<std::pair<const MyKey,MyData>*>(0) );
    AssertSameType( static_cast<MyTable::accessor::value_type*>(0), static_cast<MyTable::value_type*>(0) );
    AssertSameType( static_cast<MyTable::const_accessor::value_type*>(0), static_cast<const MyTable::value_type*>(0) );
    AssertSameType( static_cast<MyTable::size_type*>(0), static_cast<size_t*>(0) );
    AssertSameType( static_cast<MyTable::difference_type*>(0), static_cast<ptrdiff_t*>(0) );
}
void TestConcurrentQueueType() {
    AssertSameType( tbb::concurrent_queue<Foo>::value_type(), Foo() );
    Foo f;
    const Foo g;
    tbb::concurrent_queue<Foo>::reference r = f;
    ASSERT( &r==&f, NULL );
    ASSERT( !r.is_const(), NULL );
    tbb::concurrent_queue<Foo>::const_reference cr = g;
    ASSERT( &cr==&g, NULL );
    ASSERT( cr.is_const(), NULL );
}
//! Test arithmetic operators on tick_count::interval_t
void TestArithmetic( const tbb::tick_count& t0, const tbb::tick_count& t1, const tbb::tick_count& t2 ) {
    tbb::tick_count::interval_t i= t1-t0;
    tbb::tick_count::interval_t j = t2-t1;
    tbb::tick_count::interval_t k = t2-t0;
    AssertSameType( tbb::tick_count::interval_t(), i-j );
    AssertSameType( tbb::tick_count::interval_t(), i+j );
    ASSERT( i.seconds()>1E-9, NULL );
    ASSERT( j.seconds()>1E-9, NULL );
    ASSERT( k.seconds()>2E-9, NULL );
    AssertNear( (i+j).seconds(), k.seconds() );
    AssertNear( (k-j).seconds(), i.seconds() );
    AssertNear( ((k-j)+(j-i)).seconds(), k.seconds()-i.seconds() );
    tbb::tick_count::interval_t sum;
    sum += i;
    sum += j;
    AssertNear( sum.seconds(), k.seconds() );
    sum -= i;
    AssertNear( sum.seconds(), j.seconds() );
    sum -= j;
    AssertNear( sum.seconds(), 0.0 );
}
 static void apply( const MyTable& table, int i ) {
     MyTable::const_accessor a;
     const MyTable::const_accessor& ca = a;
     bool b = table.find( a, MyKey::make(i) );
     ASSERT( b==(table.count(MyKey::make(i))>0), NULL );
     ASSERT( b==!a.empty(), NULL );
     ASSERT( b==UseKey(i), NULL );
     if( b ) {
         AssertSameType( &*ca, static_cast<const MyTable::value_type*>(0) );
         ASSERT( ca->second.value_of()==~(i*i), NULL );
         ASSERT( (*ca).second.value_of()==~(i*i), NULL );
     }
 }
 static void apply( MyTable& table, int i ) {
     MyTable::accessor a;
     const MyTable::accessor& ca = a;
     bool b = table.find( a, MyKey::make(i) );
     ASSERT( b==!a.empty(), NULL );
     if( b ) {
         if( !UseKey(i) )
             REPORT("Line %d: unexpected key %d present\n",__LINE__,i);
         AssertSameType( &*a, static_cast<MyTable::value_type*>(0) );
         ASSERT( ca->second.value_of()==i*i, NULL );
         ASSERT( (*ca).second.value_of()==i*i, NULL );
         if( i&1 )
             ca->second.set_value( ~ca->second.value_of() );
         else
             (*ca).second.set_value( ~ca->second.value_of() );
     } else {
         if( UseKey(i) )
             REPORT("Line %d: key %d missing\n",__LINE__,i);
     }
 }
Exemplo n.º 7
0
void test_GetNthType() {
  AssertSameType(A, GetNthType(Int<0>, Vector<A>));
  
  AssertSameType(A, GetNthType(Int<0>, Vector<A, B>));
  AssertSameType(B, GetNthType(Int<1>, Vector<A, B>));
}