|
Boost : |
From: Joel de Guzman (djowel_at_[hidden])
Date: 2003-01-31 05:49:35
----- Original Message -----
From: "Vladimir Prus" <ghost_at_[hidden]>
> Greg Dehaas wrote:
> > Hi All,
>
> > boost::any test = "Test Me";
> [...]
> > And the error message is:
> > c:\dev\boost\boost\any.hpp(105) : error C2536: 'boost::any::holder<char
> > [8]>::held' : cannot specify explicit initializer for arrays
> > c:\dev\boost\boost\any.hpp(122) : see declaration of 'held'
> > c:\dev\boost\boost\any.hpp(103) : while compiling class-template
> > member function '__thiscall boost::any::holder<char
> > [8]>::boost::any::holder<char [8]>(const char (&)[8])'
>
> Hmm... the same problem can be seen if you try
>
> std::make_pair("1", "2");
>
> the template parameters are deduces as char[1] and char[1], and there's no
> much you can do with that type, not even copy it. That's the way template
> argument deduction works, IIRC. I suggest that you change ctors of any and
> any::holder to take value instead of reference, and tell what you got. Of
> course, you should be able to say
>
> boost::any test = static_cast<const char*>("Test me");
Yes, but a library can make it work. For instance, make_tuple("hello, ", "world")
works as expected. QOI matter?
// Arrays can't be stored as plain types; convert them to references.
template<class T, int n>
struct make_tuple_traits <T[n]> {
typedef const T (&type)[n];
};
Cheers,
Joel de Guzman
joel_at_[hidden]
http://www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk