, " " .
, :
constexpr Struct<Fields>::Struct(T&& ...) [ T = {Struct<foo<int>, bar<double> >&}; Fields = {foo<int>, bar<double>}]:
,
return f;
, .
, , , Struct. - . , Struct<foo<int>, bar<double> >&. Fields ( ), :
[..] : [..]
, ? ( ), ( Struct(Struct const &)): Struct(Struct & &&), Struct(Struct &). , f return f;: f non const lvalue.
- () :
Struct(Struct & s)
: Struct(static_cast<Struct const &>(s))
{}
volatile, , . .
- SFINAE:
template<typename T>
using decay_t = typename decay<T>::type;
template<
typename...T,
std::enable_if<
(sizeof...(T) == sizeof...(Fields))
&& not_self_helper<Struct, std::tuple<decay_t<T>...>>::value
>::type * = nullptr
>
constexpr Struct(T &&...x)
: Fields{static_cast<T&&>(x)}... {}
not_self_helper , , , :
template<typename, typename>
struct not_self_helper : std::true_type {};
template<typename Self>
struct not_self_helper<Self, std::tuple<Self>> : std::false_type {};
: . , , . , ( , ). , , , . , , "" : /.