Topic: C++0x container constructors for DefaultConstructible objects - no allocator?


Author: Howard Hinnant <howard.hinnant@gmail.com>
Date: Sat, 26 May 2007 01:07:43 CST
Raw View
In article <5bel29F2s4c3gU1@mid.individual.net>,
 bop@gmb.dk ("Bo Persson") wrote:

> Howard Hinnant wrote:
> :: In article <5b91g3F2rt1iiU1@mid.individual.net>,
> :: bop@gmb.dk ("Bo Persson") wrote:
> ::
> ::: I notice in the draft N2284 that sequence containers have had one
> ::: constructor split in two. We now have (for list<T>):
> :::
> ::: explicit list(size_type n);
> ::: list(size_type n, const T& value, const Allocator& = Allocator());
> :::
> ::: How come the first type of constructor doesn't take an allocator
> ::: parameter?
> ::
> :: Mainly just history.  People have never been able to say:
> ::
> :: std::list<T, A> c(n, A());
> ::
> :: And I've never heard any requests for that functionality.  So I
> :: didn't add it.  It easily could be added.  Is there demand for it?
> :: Would you be willing to write a short paper or defect report with
> :: detailed proposed wording relative to N2284?
> ::
>
> I was really just curious about why one constructor breaks the
> pattern. Having already written a defect report for for strings
> (#614), I noticed that other containers now also deviate from the
> container requirements in 23.1/9, where it says that constructors
> should all take an Allocator& argument. Except when they don't?
>
> I can also guess that the new constructor should default construct the
> container's allocator member, but haven't found that it says so
> anywhere. Did I miss this requirement, or is it just obvious anyway?

I've updated 614 with your comments.

http://home.twcny.rr.com/hinnant/cpp_extensions/issues_preview/lwg-active
.html#614

Thanks,
Howard

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: bop@gmb.dk ("Bo Persson")
Date: Mon, 21 May 2007 02:04:36 GMT
Raw View
I notice in the draft N2284 that sequence containers have had one
constructor split in two. We now have (for list<T>):

explicit list(size_type n);
list(size_type n, const T& value, const Allocator& = Allocator());

How come the first type of constructor doesn't take an allocator
parameter?



Bo Persson


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: Howard Hinnant <howard.hinnant@gmail.com>
Date: Mon, 21 May 2007 14:59:15 CST
Raw View
In article <5b91g3F2rt1iiU1@mid.individual.net>,
 bop@gmb.dk ("Bo Persson") wrote:

> I notice in the draft N2284 that sequence containers have had one
> constructor split in two. We now have (for list<T>):
>
> explicit list(size_type n);
> list(size_type n, const T& value, const Allocator& = Allocator());
>
> How come the first type of constructor doesn't take an allocator
> parameter?

Mainly just history.  People have never been able to say:

std::list<T, A> c(n, A());

And I've never heard any requests for that functionality.  So I didn't
add it.  It easily could be added.  Is there demand for it?  Would you
be willing to write a short paper or defect report with detailed
proposed wording relative to N2284?

-Howard

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: bop@gmb.dk ("Bo Persson")
Date: Mon, 21 May 2007 22:44:14 GMT
Raw View
Howard Hinnant wrote:
:: In article <5b91g3F2rt1iiU1@mid.individual.net>,
:: bop@gmb.dk ("Bo Persson") wrote:
::
::: I notice in the draft N2284 that sequence containers have had one
::: constructor split in two. We now have (for list<T>):
:::
::: explicit list(size_type n);
::: list(size_type n, const T& value, const Allocator& = Allocator());
:::
::: How come the first type of constructor doesn't take an allocator
::: parameter?
::
:: Mainly just history.  People have never been able to say:
::
:: std::list<T, A> c(n, A());
::
:: And I've never heard any requests for that functionality.  So I
:: didn't add it.  It easily could be added.  Is there demand for it?
:: Would you be willing to write a short paper or defect report with
:: detailed proposed wording relative to N2284?
::

I was really just curious about why one constructor breaks the
pattern. Having already written a defect report for for strings
(#614), I noticed that other containers now also deviate from the
container requirements in 23.1/9, where it says that constructors
should all take an Allocator& argument. Except when they don't?

I can also guess that the new constructor should default construct the
container's allocator member, but haven't found that it says so
anywhere. Did I miss this requirement, or is it just obvious anyway?


Bo Persson


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]