Пример #1
0
 ////////////////////////////////////////////////////////////////////////////
 // is_aligned(a0,a1) check if a0 is aligned on a1
 ////////////////////////////////////////////////////////////////////////////
 template<class A0, class A1> inline
 typename meta::enable_call<tag::is_aligned_(A0 const&, A1 const&)>::type
 is_aligned(A0 const& a0, A1 const& a1)
 {
   NT2_ASSERT(   is_power_of_2(a1)
             &&  "Invalid alignment boundary. You tried to check if an "
                 "address or a value is aligned on a non-power of 2 boundary."
             );
   typename make_functor<tag::is_aligned_, A0>::type callee;
   return callee(a0,a1);
 }
Пример #2
0
int main()
{
  nt2::memory::buffer<int> b1(0,5);
  nt2::memory::buffer<int> b2(-3,5);

  //Update first element
  b1[0]  = 1;
  b2[-3] = 2;
  
  //update last element 
  b1[4]  = *(b1.begin()) + 1;
  b2[-3] = *(b2.begin()) + 1;

  NT2_ASSERT( *(b1.begin()) == b1[0]  );
  NT2_ASSERT( *(b2.begin()) == b2[-3] );

  std::cout << "Buffer 1 size  = " << b1.size()  << std::endl;
  std::cout << "Buffer 2 size  = " << b1.size()  << std::endl;
  
  return 0;
}