C++ non-type template parameter const char*

前端 未结 2 1222
不思量自难忘°
不思量自难忘° 2020-12-11 03:53

Let\'s say we have

template 
struct A{};

// static storage
const char a[] = \"asd\";
const char* p = \"asd\";

This inst

2条回答
  •  情话喂你
    2020-12-11 04:45

    It may help to understand more why A

    {}; is not allowed if you imagine p is initialized by some function

    const char* p = getP();
    

    where getP() determines its result by some runtime data, for example, by reading a config file.

提交回复
热议问题