Run Code
|
API
|
Code Wall
|
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
Crow unordered_map Quiz
Class operator overloading the subscript and boundary check for array
UTF-8 in C++11
Copy uint64 data into uint32 with padding
Specialization on signed types
user defined exception
le regime keto aviss
Reference example
hello world 3
for_each_argument