バリデーショナルなテンプレートを試してみましたが、何らかの操作で特性値を最終的な値に一種減らすのが便利な点がありました。私にとってのユースケースは、variadicテンプレートパラメータの特性値を1つの値に減らすにはどうすればよいですか?
constexpr bool and(bool lhs, bool rhs){return lhs && rhs;}
struct Foo
{
template<
typename ...Ts>
Foo(
Ts&&... args)
noexcept(TraitReduction<std::is_nothrow_move_constructible, and, Ts...>::value)
{/*...*/}
}
です。問題は、STLの特性がすべて単一のテンプレート型であることです。 私の現在の作業ソリューションです:STLは、そのタスクsolutionforいくつかの標準化された(おそらくより便利な)を与える場合
template<
template<typename> class TraitT,
bool (*Operator)(bool,bool),
typename T1,
typename ...Ts>
struct TraitReduction
{
static bool const value = TraitT<T1>::value;
};
template<
template<typename> class TraitT,
bool (*Operator)(bool,bool),
typename T1,
typename T2,
typename ...Ts>
struct TraitReduction<
TraitT,
Operator,
T1,
T2,
Ts...>
{
static bool const value = (*Operator)(
TraitT<T1>::value,
TraitReduction<TraitT, Operator, T2, Ts...>::value);
};
私の質問はありますか?もちろん、私の現在の解決策に関するコメントや、何が悪いのか、何が良いのかについては、ここで嬉しく思います。
'noexcept()(is_nothrow_move_constructible {}と...) ' –
0x499602D2
この特殊なケースは[' std :: connections'](http://en.cppreference.com/w/cpp/types/conjunction)の仕事のように見えますが、もっと一般化されたアプローチを探しているのなら、それは十分ではありません – krzaq
'と'は '&&'の別のスペルですよね? –