We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#include "../all.h" void f(const int &){ std::cout << "lvalue\n"; } void f(const int &&){ std::cout << "rvalue\n"; } int main(){ int object {}; f(object); f(object + object); f([&]{ return object; }()); f(std::move(object)); }
$ g++ -std=c++17 -Wall lvalue-and-rvalue.cpp lvalue-and-rvalue.cpp: In lambda function: lvalue-and-rvalue.cpp:15:16: error: ‘object’ is not captured 15 | f([]{ return object; }()); | ^~~~~~ lvalue-and-rvalue.cpp:15:6: note: the lambda has no capture-default 15 | f([]{ return object; }()); | ^ lvalue-and-rvalue.cpp:11:7: note: ‘int object’ declared here 11 | int object {}; | ^~~~~~
https://twitter.com/TartanLlama/status/1283816537778982914 を思い出した。 試しに object を constexpr にしたらコンパイルされた。
object
constexpr
The text was updated successfully, but these errors were encountered:
No branches or pull requests
再現コード
実行結果
おまけ
https://twitter.com/TartanLlama/status/1283816537778982914 を思い出した。
試しに
object
をconstexpr
にしたらコンパイルされた。The text was updated successfully, but these errors were encountered: