tipo de localização, para o qual is_constructible mantém

Eu estava brincando com modelos e estava tentando implementar o seguinte ajudante.

first_constructible<Types..., Args...>::type

que retornaria o primeiro tipo deTypes que é construtível a partir deArgs.... O primeiro problema obviamente é ter dois pacotes de parâmetros emstruct, então mudei o uso para

first_constructible<std::tuple<Types...>, Args...>::type

Eu o implementei dividindo os tipos de tupla como primeiro e restante, verificados usandostd::is_constructible e recorrente se necessário.

template<typename T>
struct pop_front_tuple
{
    template<typename U, typename... Us>
    static std::tuple<Us...> impl(std::tuple<U, Us...>);

    using type = decltype(impl(std::declval<T>())); // std::tuple with removed first type
};

template<typename Tuple, typename... Args>
struct first_constructible
{
    using first_type = decltype(std::get<0>(std::declval<Tuple>()));

    using type = typename std::conditional
    <
        std::is_constructible<first_type, Args...>::value,
        first_type,
        typename first_constructible<typename pop_front_tuple<Tuple>::type, Args...>::type
    >::type;
};

// end of recursion
template<typename... Args>
struct first_constructible<std::tuple<>, Args...>
{
    using type = void;
};

mas por algum motivo não funciona. I.e

first_constructible<std::tuple<std::string, int>, std::string>::type a = ""; // works, a is std::string
first_constructible<std::tuple<std::string, int>>::type a = ""; // fails, error: variable or field 'a' declared void
first_constructible<std::tuple<std::string, int>, std::string::size_type, std::string::value_type> // fails, same error

Não sei onde está o meu erro.std::is_constructible<std::string>::value estd::is_constructible<std::string, std::string::size_type, std::string::value_type>::value são verdadeiras.

Coliru link

questionAnswers(4)

yourAnswerToTheQuestion