|
Boost : |
Subject: Re: [boost] [shared_array] Why not in C++11 ?
From: Sid Sacek (ssacek_at_[hidden])
Date: 2013-07-07 18:23:49
Peter Dimov wrote:
> > Once C++14 becomes an official standard, it'd become possible for
> > N3640 to be discussed and, hopefully, accepted;
>
> Same goes for N3641, of course.
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3641.html
I tried it out for the first time.
Actually, I tried out:
auto buffer = boost::make_shared< unsigned char[] >( 1234 );
which created an appropriate: shared_ptr< unsigned char [0] >
I was ok with that. I then peeked into all the values stored inside the counter object and even saw the size of the array stored there.
I then tried to get the buffer length (in code) but hit a brick wall.
int len = buffer.length; // doesn't exist
int len = buffer.length(); // doesn't exist
int len = buffer.capacity; // doesn't exist
int len = buffer.capacity(); // doesn't exist
int len = buffer.size; // doesn't exist
int len = buffer.size(); // doesn't exist
Unless I'm not using the object correctly, not being able to retrieve the array's capacity is a major oversight in my opinion.
As a library developer, I want to be passed buffers in this fashion, and know how much data a buffer can hold. Having to guess is not what I was hoping for. Both Java and C# allow you to do this, so why not C++ buffers.
-Sid
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk