Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • This certainly looks cleaner than the template hack, but it does not seem to work: implctstringparam.cpp: In function ‘void foo(const char*)’: implctstringparam.cpp:9: error: ‘s’ cannot appear in a constant-expression Commented Jun 27, 2011 at 8:42
  • The const std::string& s would most likely need to be static inorder for static assertion to work. Commented Mar 2, 2012 at 16:35
  • 3
    The value of s is only known at runtime, when the function is called: you cannot use it in a static_assert, which is evaluated at compile-time. A static_assert can only evaluate constant expressions. Commented Jul 31, 2012 at 22:28