Peter Foelsche wrote:
I suggested some time ago to add a special constructor:
template
any(T _ap[SIZE]); which should do the same like any(T *_p);
Ferdinand Prantl wrote:
Well, a little shorter as the static_cast version but still a "superfluous" cast.
I could not find anything about it but the thread which I referred in the first post to. Do you remember why the constructor has not been added to the official version?
I don't know, but it makes sense to me: an array is not just a pointer!
boost::any always stores a /copy/ of its constructor argument or
assignment argument. So /if/ it would support built-in arrays, I think
it should copy their elements internally. Still, it appears technically
possible to add array support to boost::any, e.g., by having it
internally hold a wrapper<ValueType>, instead of a ValueType object (as
holder<ValueType>::held data member):
template<typename ValueType>
struct wrapper
{
ValueType data;
explicit wrapper(const ValueType & value)
: data(value)
{
}
};
The wrapper would need to be specialized for array types, copying the
array elements during construction:
template