|
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
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48468 ?
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)...)`.
P.S.
I requested adding `noexcept` to `boost::declval`.
https://svn.boost.org/trac/boost/ticket/6570
Regards,
Michel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk