Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-01-31 07:44:10


Joel de Guzman wrote:

>>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?

I guess so. (Hmm.. I recall that the proposes solution for std::pair is to
make it accept value, not reference, and don't know the motivation, except
that this solution is the simplest)

> // 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];
> };

Wait a minute! If T[n] is converted to T[n]&, then it would mean
make_tuple("1", "2") and make_tuple("1", "23") will generate different
template specializations? I'd rather convert T[n] to T*, but probably I
miss something.

- Volodya


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk