Opened 16 years ago
Closed 15 years ago
#818 closed Bugs (fixed)
No zero-argument in_place()
| Reported by: | nobody | Owned by: | Fernando Cacciola |
|---|---|---|---|
| Milestone: | Boost 1.35.0 | Component: | None |
| Version: | None | Severity: | Problem |
| Keywords: | Cc: |
Description
There is no zero-argument version of boost::in_place(). I would have expected this to exist, and to be a factory for a type's default constructor.
This is necessary when attempting to use boost::optional with a type that is not CopyConstructible, or where the copy constructor is expensive:
#include <boost/optional.hpp>
#include <boost/utility/in_place_factory.hpp>
boost::optional<my_type> my_optional;
my_optional = boost::in_place();
I'm not aware of any other way to initialise a boost::optional to a default-constructed instance without unnecessary and perhaps impossible copying.
--Clive.
(clive-nospam-boost.org@nsict.org)
Change History (2)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
| Milestone: | → Boost 1.35.0 |
|---|---|
| Resolution: | None → fixed |
| Severity: | → Problem |
| Status: | assigned → closed |
The improved version contributed by Tobias Schwinger (which allows zero-argument factories) is now on the trunk. The docs still need to be updated though.
Note:
See TracTickets
for help on using tickets.

There is an implementacion of place with zero-argument in http://www.boost-consulting.com/vault/index.php?direction=0&order=&directory=Utilities
The poly_obj.tar.gz contains the file poly_obj.hpp and it´s there an in_place with zero-argument. It runned OK in my system. Anyone could check it out and put in release? Thanks..