php多语言网站怎么做搭建网站基本步骤
C++20中引入了std::source_location,用来描述函数调用的上下文信息。
其主要的成员函数如下:
line():获取行号。column():获取列号。file_name():获取文件名。function_name():获取函数域名。
#include <iostream>
#include <string_view>
#include <source_location>void 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!
