参考https://en.cppreference.com/w...下面,这一行:xvaluea[n],thebuilt-insubscriptexpression,whereoneoperandisanarrayrvalue;那么什么是arrayrvalue呢?参考https://en.cppreference.com/w...下面说到对于expr1[expr2]Whenappliedtoanarray,thesubscriptexpressionisanlvalueifthearrayisanlvalue,andanxvalueifitisn't(sinceC++11).什么时候数组不是一个左值呢?参考下面代码structS{intiarr[10];inti;std::stringsarr[10];std::strings;};Sget(){returnS{};}templatevoidfoo(T&&v){}intmain(){foo(get().iarr[0]);//int&foo(get().i);//int&&foo(get().sarr[0]);//std::string&foo(get().s);//std::string&&return0;}根据cppreference的说法:get()返回的是prvalueget().m应该是xvalueget().m[n]是xvalue吗?
慕虎7371278
千万里不及你
随时随地看视频慕课网APP
相关分类