Boost logo

Boost :

Subject: Re: [boost] make_shared_array
From: Nathan Crookston (nathan.crookston_at_[hidden])
Date: 2012-11-06 11:13:36


I see that a commit with the following syntax has occurred on trunk.
On Fri, Nov 2, 2012 at 6:20 PM, Peter Dimov <lists_at_[hidden]> wrote:
> shared_ptr<int[]> sp4a = make_shared<int[]>(number_of_ints);//4a:
> initialized to 0
> shared_ptr<int[]> sp4b = make_shared_noinit<int[]>(number_of_ints);//4b:
> uninitialized

I have one minor suggestion.

Given that the make_shared variant which produces shared_ptr<T[]> is
spelled make_shared<T[]>, I think it would be very confusing to have
the following not work:
#include <boost/make_shared.hpp>

int main()
{
  auto pInt = boost::make_shared<int[]>(500);
  return 0;
}

I would suggest that make_shared_array.hpp be included by
make_shared.hpp -- likewise for allocate_shared. Perhaps the array
header files should be placed in detail, though I think it's less
confusing to include make_shared_array.hpp and not have the non-array
make_shared functions.

Thanks,
Nate


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk