这previously answered question解释了为什么我下面发布的代码不起作用。我有一个后续问题:是否有一种解决方案在概念上是等价的,即实现编译时字符串连接,但以C++ 11实际支持的方式实现?使用std :: string是完全不必要的。constexpr带字符串操作的解决方法?
constexpr std::string foo() { return std::string("foo"); }
constexpr std::string bar() { return std::string("bar"); }
constexpr std::string foobar() { return foo() + bar(); }
所以你想要编译时字符串连接? – 2012-01-29 04:23:01