我最近讀到的文字已經放在命名空間std::literals
中,像s
,h
,ms
等等。所以如果我要使用它們,那麼我應該包含名稱空間或使用std::literals::
來表示這些後綴。然而,當我嘗試以下程序(cpp.sh/9ytu)不使用任何上述我所需要的輸出: -使用沒有std :: literals的後綴
#include <iostream>
#include <thread>
using namespace std;
int main()
{
auto str = "He is there"s;
auto timegap = 1s;
cout << "The string is :-" << endl;
this_thread::sleep_for(timegap);
cout << str;
return 0;
}
/*Output:-
The string is :-
He is there
*/
正如你可以看到我已經不包含在任何namespace
或std::literals::
還是我的程序正常運行。我試過Orwell DevC++,C++ Shell,Coliru &無處不在。有什麼問題?
你有'使用命名空間標準;'和文字駐留在'標準'裏面的內聯命名空間,不是嗎? –
總是標記「C++」,否則例如語法突出顯示被禁用。 – Columbo
ok @Columbo我會 –