std :: remove_const com referências const

Porquestd::remove_const não converterconst T& paraT&? Este exemplo reconhecidamente bastante inventado demonstra a minha pergunta:

#include <type_traits>

int main()
{
    int a = 42;
    std::remove_const<const int&>::type b(a);

    // This assertion fails
    static_assert(
        !std::is_same<decltype(b), const int&>::value,
        "Why did remove_const not remove const?"
    );

    return 0;
}

O caso acima é trivialmente fácil de corrigir, portanto, para o contexto, imagine o seguinte:

#include <iostream>

template <typename T>
struct Selector
{
    constexpr static const char* value = "default";
};

template <typename T>
struct Selector<T&>
{
    constexpr static const char* value = "reference";
};

template <typename T>
struct Selector<const T&>
{
    constexpr static const char* value = "constref";
};

int main()
{
    std::cout
        << Selector<typename std::remove_const<const int&>::type>::value
        << std::endl;

    return 0;
}

No exemplo acima, eu esperariareference para ser mostrado, em vez deconstref.

questionAnswers(1)

yourAnswerToTheQuestion