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
problem_name_2
Copy uint64 data into uint32 with padding
bubble sort
Peregruzka
Zadanie Dejwu
AnnotateAttr templated test
Throttle Example in C++ (80 requests every 2 seconds)
Optional conversions
Exploring stringstreams
Move Construction