|
Boost : |
Subject: [boost] [optional] compatibility with arrays
From: Craig Henderson (cdm.henderson_at_[hidden])
Date: 2009-09-07 17:37:35
I am using boost::optional but have hit a problem with arrays. Using MSVC8,
the definition
boost::optional<char[R] > foo_;
produces a compilation error:
boost_1_39_0\boost/optional/optional.hpp(315) : error C2075: 'Target of
operator new()' : array initialization needs curly braces
boost_1_39_0\boost/optional/optional.hpp(314) : while compiling class
template member function 'void
boost::optional_detail::optional_base<T>::construct(const char (&))'
with
[
T=char [3]
]
boost_1_39_0\boost/optional/optional.hpp(455) : see reference to class
template instantiation 'boost::optional_detail::optional_base<T>' being
compiled
with
[
T=char [3]
]
There is no mention of non-arrays in the type requirements, so I don't know
if this is specific to MSVC8, or a general/known problem?
I have overcome the problem using boost::array
boost::optional<boost::array<char,R> > foo_;
Is there an opportunity to detect an array and substitute a boost::array for
the given type?
Thanks
-- Craig
Craig Henderson
<http://craighenderson.co.uk/> http://www.craighenderson.co.uk
http://www.siteupdatenotification.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk