Boost logo

Boost Users :

From: Paweł Sikora (pawels_at_[hidden])
Date: 2007-01-08 10:45:09


Robert Mecklenburg napisał(a):

> int main(int , char **)
> {
> boost::array<char, 6> barray;
> std::cout << sizeof(barray) << std::endl;
> std::tr1::array<char, 6> tr1array;
> std::cout << sizeof(tr1array) << std::endl;
> }
>
> When run this code produces:
>
> g++ foo.cpp && ./a.out
> 6
> 16
>
> That is, the boost array is exactly the size I require 6 bytes, but
> the tr1 array is larger, 16 bytes.

the array is fine, just check the size() and use data().
implementation details are not our business.

$ cat test.cpp
#include <boost/array.hpp>
#include <tr1/array>
#include <cstdio>

int main()
{
         boost::array< char, 6 > barray;
         std::printf( "barray size = %Zd, raw ptr = %p\n",
                 barray.size(), barray.data() );
         std::tr1::array< char, 6 > tr1array;
         std::printf( "tr1array size = %Zd, raw ptr = %p\n",
                 tr1array.size(), tr1array.data() );
         return 0;
}

$ ./test
barray size = 6, raw ptr = 0x7fffffd038c0
tr1array size = 6, raw ptr = 0x7fffffd038b0

-- 
to_be || !to_be == 1, to_be | ~to_be == -1

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net