I was writing a program for hashtables. The hashtable has pairs. first
is a string and second
belongs to a template class.
Need to initialize the template class as a string to return a default value when looking up strings.
template<typename T>
struct default_value;
template<>
struct default_value<int> {
static constexpr int value = 0;
};
template<>
struct default_value<double> {
static constexpr double value = NULL;
};
template<>
struct default_value<float> {
static constexpr float value = NULL;
};
template<>
struct default_value<string> {
static constexpr string_view value{""};
};
Currently, I am getting an error when I do the above for the string
. I understand I cannot use constexpr
for string and so I decided to use string_view
. I have imported string_view
already