--- any.hpp.orig Sun Nov 25 19:07:20 2007 +++ any.hpp Wed Jul 9 15:50:13 2008 @@ -15,6 +15,7 @@ #include "boost/config.hpp" #include +#include #include #include #include @@ -36,6 +37,12 @@ { } + template + any(const ElementType (& value)[NumberOfElements]) + : content(new holder(value)) + { + } + any(const any & other) : content(other.content ? other.content->clone() : 0) { @@ -102,6 +109,28 @@ }; template + struct wrapper + { + ValueType data; + + explicit wrapper(const ValueType & value) + : data(value) + { + } + }; + + template + struct wrapper + { + typename remove_const::type data[NumberOfElements]; + + explicit wrapper(const ElementType (& value)[NumberOfElements]) + { + std::copy(value, value + NumberOfElements, data); + } + }; + + template class holder : public placeholder { public: // structors @@ -120,12 +149,12 @@ virtual placeholder * clone() const { - return new holder(held); + return new holder(held.data); } public: // representation - ValueType held; + wrapper held; }; @@ -163,7 +192,7 @@ ValueType * any_cast(any * operand) { return operand && operand->type() == typeid(ValueType) - ? &static_cast *>(operand->content)->held + ? &static_cast *>(operand->content)->held.data : 0; } @@ -216,7 +245,7 @@ template inline ValueType * unsafe_any_cast(any * operand) { - return &static_cast *>(operand->content)->held; + return &static_cast *>(operand->content)->held.data; } template