Boost logo

Boost :

Subject: [boost] [any] Divergence between Boost.Any and standard library proposal
From: Beman Dawes (bdawes_at_[hidden])
Date: 2013-05-03 11:32:51


A fresh draft of the proposal is up at
http://beman.github.com/dot16/any-proposal.html

In testing new any_cast examples, Boost.Any is handling one case
differently from the proposal:

     any x;
     ...
     x = "Meow"; // x holds const char*

This works fine with the Adobe implementation, but with the Boost
implementation g++ 4.7.0 -std=c++11 reports:

In file included from any_cast_test.cpp:5:0:
c:\boost\trunk/boost/any.hpp: In instantiation of
'boost::any::holder<ValueType>::holder(c
onst ValueType&) [with ValueType = char [5]]':
c:\boost\trunk/boost/any.hpp:52:49: required from
'boost::any::any(const ValueType&) [wi
th ValueType = char [5]]'
c:\boost\trunk/boost/any.hpp:124:13: required from 'boost::any&
boost::any::operator=(Va
lueType&&) [with ValueType = const char (&)[5]; boost::any = boost::any]'
any_cast_test.cpp:79:7: required from here
c:\boost\trunk/boost/any.hpp:169:27: error: array used as initializer

VC++ 2012 gets the same error, albeit with a much longer set of messages.

AFAICS, the Adobe (and the proposed standard) behavior is preferred.
The type does need to decay.

Comments?

--Beman


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