Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Linker error while passing constexpr variable as const &
#include <iostream> struct A { static constexpr int Max = 17; }; void PrintRef (const int& x) { std::cout << "x == " << x << std::endl; } void Print(int x) { std::cout << "x == " << x << std::endl; } int main() { Print (A::Max); // OK Print (A::Max + 0); // OK //PrintRef(A::Max); // linker error: undefined reference to `A::Max' PrintRef(A::Max + 0); // OK } // is reason? // 17 is a const expression (not a reference) // 17+0 would return a rvalue (a reference)
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Crow unordered_map Quiz
Reference example
Balanced Insert Heap Example
lref assignment
Program_3
UTF-8 in C++11
Set sub sequences.
001
Own initialization
boost::geometry::distance performance overhead compared to a straightforward implementation
Please log in to post a comment.