Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:13

0001 // name=ConstExprTest ; gcc $name.cc -std=c++11 -lstdc++ -o /tmp/$name && /tmp/$name
0002 
0003 /**
0004 
0005 https://stackoverflow.com/questions/29844028/explain-constexpr-with-const-charconst
0006 
0007 
0008 https://en.cppreference.com/w/cpp/language/constexpr
0009     constexpr is since C++11
0010 
0011     The constexpr specifier declares that it is possible to evaluate the value of
0012     the function or variable at compile time. Such variables and functions can then
0013     be used where only compile time constant expressions are allowed (provided that
0014     appropriate function arguments are given).
0015 
0016 
0017 *In summary think of constexpr as more const than const : a compile time constant*   
0018 
0019 **/
0020 
0021 
0022 struct ConstExprTest 
0023 {
0024     static constexpr const char* STR = "some useful string constant";
0025 };
0026 
0027 
0028 #include <iostream>
0029 
0030 int main()
0031 {
0032     std::cout << ConstExprTest::STR << std::endl ; 
0033     return 0 ; 
0034 }
0035