Я пытаюсь получить ссылку на константную строку в качестве аргумента шаблона, отличного от типа, я не могу пройти мимо этой ошибки компиляции.
тест.ч :
#include <string.h>
#include <iostream>
template<const std::string& V> class TestTmplt
{
};
const std::string& TEST_REF = "TESTREF" ;
typedef TestTmplt<TEST_REF> TestRefData ;
test.cpp:
#include <test.h>
template class TestTmplt<TEST_REF> ;
Ошибка компиляции:
./test.h:10:34: error: could not convert template argument âTEST_REFâ to âconst string& {aka const std::basic_string<char>&}â
./test.h:10:49: error: invalid type in declaration before â;â token
Я компилирую Centos Linux, используя следующую команду gcc
g++ -c -MMD -MF test.u -g -D_LINUX -std=c++03 -pthread -Wall -DVALGRIND -Wno-missing-field-initializers -z muldefs -I. -o test.o test.cpp