Alias data type for template specialization

Viewed 32

I would like to simply differentiate between two unsigned integers in template specialization. Ideally i would like to use

using TextureID = unsigned int;

But this is not possible since TextureID is exactly the same as an unsigned int for the compiler.

So I "solved" my problem by using enum class:

enum class TextureID : unsigned int
{
    Default = 0     
}; 

template<typename T>
inline void GuiSystem::InputField<T>(const char* name, T* value)
{}

template<>
inline void GuiSystem::InputField<unsigned int>(const char* name, unsigned int* value)
{
    Log("unsigned int");
}

template<>
inline void GuiSystem::InputField<TextureID>(const char* name, TextureID* value)
{
    int tempValue = int(*value);
    ImGui::InputInt(name, &tempValue);
    *value = TextureID(glm::max(0, tempValue));
    Log("TextureID");
}

However I think enum class is not the cleanest solution to the problem.

What is the easiest way to alias a data type for template specialization?

0 Answers
Related