Boost logo

Boost :

Subject: Re: [boost] Updated boost::base_from_member for C++2011
From: Michel Morin (mimomorin_at_[hidden])
Date: 2012-02-16 22:12:00

Daryle Walker wrote:
> The way around it is to add an "unused" EnableIf template parameter to
> the constructor template that cancels the template when Args is a single
> argument and the argument's type is MyType.

How about using SFINAE to `noexcept` operator as in ?

template <typename... T, bool NoExcept = BOOST_NOEXCEPT_EXPR(......)>
explicit BOOST_CONSTEXPR base_from_member( T&& ...x )
    BOOST_NOEXCEPT_IF( NoExcept ) // no std::is_nothrow_constructible...
    : member( static_cast<T&&>(x)... ) // ...nor std::forward needed

This seems a bit simpler, but of course, it might be a personal taste ;)

In `bool NoExcept = BOOST_NOEXCEPT_EXPR(...…)`,
we have to use `MemberType(boost::declval<T>()...)`
instead of `MemberType(static_cast<T&&>(x)...)`.

I requested adding `noexcept` to `boost::declval`.


Boost list run by bdawes at, gregod at, cpdaniel at, john at