Boost logo

Boost :

Subject: Re: [boost] [variant] Opinion on boost::safe_get<> and default boost::get<> behavior
From: Matt Calabrese (rivorus_at_[hidden])
Date: 2014-12-09 13:00:12


On Tue, Dec 9, 2014 at 9:39 AM, Peter Dimov <lists_at_[hidden]> wrote:

> There's nothing wrong (or unsafe) with the old behavior - it consistently
> answers the question "does v contain a T" - so the decision can't be made
> based on principles alone and must be informed by practice. That is, do the
> benefits of the strict get - which are pretty much only catching your typo
> when you say get<T>(v) instead of get<T>(w) - outweigh the loss of
> functionality.

While that's true, the old behavior seems about as compelling to me as if
the language allowed you to static_cast between any two types, but yielded
a null pointer at run-time if there were no valid conversion. Even if it
breaks a bunch of code it's probably better in the long run, unless there
are interesting idiomatic use-cases.

-- 
-Matt Calabrese

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