Код: Выделить всё
#include
using namespace std;
template
void print() {
cout
error: ‘myStr’ is not a valid template argument of type ‘const char*’ because ‘myStr’ has no linkage
< /code>
В Clang 3.4.1 ошибки кода с < /p>
candidate template ignored: invalid explicitly-specified argument for template parameter 'Str'
A link to an online compiler where you can select one of many C++ compilers.
Note, moving myStr outside main compiles and runs as expected.
Note, I have looked at similar StackOverflow questions from before C ++ 11, и большинство указывает на то, что это должно быть разрешено в C ++ 11. Например, использование локальных классов с алгоритмами STL
Подробнее здесь: https://stackoverflow.com/questions/269 ... -arguments