推論ではありません次のコードスニペットを考えてみてください:テンプレートパラメータは
template<class E>
class vector_expression {};
template<class Tuple>
class vector
: public vector_expression<vector<Tuple>>
{
public:
using value_type = typename Tuple::value_type;
};
template<typename T>
using dynamic_vector = vector<std::vector<T>>;
namespace detail
{
template<class E>
constexpr bool is_vector_expression_v = std::is_base_of_v<vector_expression<std::decay_t<E>>, std::decay_t<E>>;
template<class E>
struct value_type { using type = std::decay_t<E>; };
template<class E>
struct value_type<vector_expression<std::decay_t<E>>> { using type = typename std::decay_t<E>::value_type; };
template<class E>
using value_type_t = typename value_type<E>::type;
}
int main()
{
static_assert(std::is_same<detail::value_type_t<dynamic_vector<double>>, double>::value, "not the same");
return 0;
}
私はvalue_type_t<E>
がE
がvector_expression
である時はいつでもE
で指定value_type
になりたいです。上記のコードが機能していないため、テンプレートパラメータE
は、部分的な特殊化value_type
では推測できません。コードを動作させるにはどうしたらいいですか?
[こちら](http://coliru.stacked-crooked.com/a/35a7e10935ac63a0)のように? –