$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] boost::any with const value types
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2016-07-07 19:31:39
On 8/07/2016 09:24, Steven Watanabe wrote:
> Yes, this is by design. The rule is that
> you can only get out the same type that you
> put in. char * is not the same type as
> char const *.
It would be nice if it followed the implicit const rules, eg. such that
if a "char *" is stored it would be possible to retrieve either a "char
*" or a "char const *" from it. (This is not currently the case, at
least not in 1.55.)
The reverse must not be possible though -- if a "char const *" is stored
then it must be illegal to retrieve a "char *" as this violates const
correctness.
Although then I suppose it might raise arguments about implicit
conversions as well (eg. storing short and fetching int), which are
edging closer to a gray area, and which Boost.Any explicitly disavows.