Boost logo

Boost :

Subject: Re: [boost] the Boost policy for protecting against "too perfect forwarding"
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2014-04-25 11:17:12


On Friday 25 April 2014 16:48:03 Andrzej Krzemienski wrote:
> Hi,
> By "too perfect forwarding" I mean the issue described in either of the
> following articles:
> http://akrzemi1.wordpress.com/2013/10/10/too-perfect-forwarding/
> http://flamingdangerzone.com/cxx11/2012/06/05/is_related.html
> http://ericniebler.com/2013/08/07/universal-references-and-the-copy-construc
> to/
>
> In short, a perfect-forwarding constructor can inadvertently become a
> better match than a copy constructor when we want to make a copy.
>
> There are two ways for protecting against it:
> 1. enable_if -- to disable the unwanted overloads
> 2. Add additional constructor overloads.
>
> (1) appears cleaner, but some compilers might not support SFINAE.
>
> My question is if there is a consensus in Boost how to approach this
> problem. Is Boost supposed to support compilers w/o SFINAE? (It looks so,
> because we have macro BOOST_NO_SFINAE.
>
> I can see Boost.Any just uses SFINAE for this purpose without any check.
>
> Are there any compilers supported by Boost that have rvalue references but
> no SFINAE?

I think you can safely rely on SFINAE with any recent compiler.
BOOST_NO_SFINAE was used with ancient compilers and there even was initiative
of removing it, if I'm not mistaken.


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