[英]Why VS2015 intellisense shows error on C++11 user defined literals (UDL)
The below code can be compiled and run, but VS2015 intellisense shows error. 下面的代码可以编译并运行,但是VS2015 intellisense显示错误。 g++ & eclipse has the same issue (compiled & run but shows error)
g ++和Eclipse具有相同的问题(已编译并运行,但显示错误)
Does anyone know how to fix it? 有谁知道如何修理它? I tried searching on google but hopeless.
我尝试在Google上搜索,但无望。 The error is a little annoying.. :-)
错误有点烦人.. :-)
#include <iostream>
#include <thread>
#include <chrono>
using namespace std;
using namespace std::literals;
using namespace chrono_literals;
int main()
{
this_thread::sleep_for(5s);
cout << "test \n";
return 0;
}
Error message: "Invalid suffix 's' on integer literal" 错误消息: “整数文字上的后缀's'无效”
Thanks a lot! 非常感谢!
You should add some #include
statements and namespace
references: 您应该添加一些
#include
语句和namespace
引用:
#include <iostream>
#include <chrono>
#include <thread>
int main()
{
using namespace std::literals::chrono_literals;
std::this_thread::sleep_for(5s);
std::cout << "test \n";
return 0;
}
In your code, the compiler is not been told to use namespace std
. 在您的代码中,未告知编译器使用名称空间
std
。 The 5s does not work without std::literals
没有
std::literals
,5s不能工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.