网站设计和网页设计,四平网站建设电话,C2C电子商务网站管理系统,杭州企业seo网站优化C++20中引入了std::source_location,用来描述函数调用的上下文信息。
其主要的成员函数如下: line():获取行号。column():获取列号。file_name():获取文件名。function_name():获取函数域名。#include iostream
#include string_view
#include sour…C++20中引入了std::source_location,用来描述函数调用的上下文信息。
其主要的成员函数如下:
line():获取行号。column():获取列号。file_name():获取文件名。function_name():获取函数域名。#include iostream
#include string_view
#include source_locationvoid log(std::string_view message, const std::source_location location = std::source_location::current())
{std::cout location.file_name() ':' location.line() ' ' "func:"location.function_name() ' ' "log:"message '\n';
}int main()
{log("Hello world!");
} 运行程序输出: ./file.cpp:16 func:int main() log:Hello world!