開發平台(Platform): (Ex: Win10, Linux, ...)
Linux
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
GCC
最近再努力看懂rvalue相關的東西,看到一篇文章
有個人寫了is_lvalue他本來沒加"constexpr"可是有人建議他補上
他後來也補上了~想請問這個會有什麼差別嘛??
我看這好像看反編譯的結果好像也不能再編譯期就知道結果?
想問真的有加上的必要嘛??
https://reurl.cc/mLl5Wl
#include <iostream>
template <typename T>
constexpr bool is_lvalue(T&) {
return true;
}
template <typename T>
constexpr bool is_lvalue(T&&) {
return false;
}
int main()
{
std::string a = std::string("Hello");
std::cout << "Is lValue ? " << '\n';
std::cout << "std::string() : " << is_lvalue(std::string()) << '\n';
std::cout << "a : " << is_lvalue(a) << '\n';
std::cout << "a+b : " << is_lvalue(a+ std::string(" world!!! ")) << '\n';
}