Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ source_location::current()作为默认的非类型模板参数计算_C++_C++20_Std Source Location - Fatal编程技术网

C++ source_location::current()作为默认的非类型模板参数计算

C++ source_location::current()作为默认的非类型模板参数计算,c++,c++20,std-source-location,C++,C++20,Std Source Location,介绍源位置::当前: 作为默认参数([dcl.fct.default])或其子表达式出现的对current的任何调用都应与使用默认参数([expr.call])的函数调用位置相对应 请注意,“default argument()”包括默认模板参数,但上面的引号仅表示“函数调用的位置”。在默认模板参数的上下文中计算source\u location::current()是否合法 考虑以下代码(): #包括 //#包括 #包括 //使用source\u location=std::source\u

介绍
源位置::当前

作为默认参数([dcl.fct.default])或其子表达式出现的对
current
的任何调用都应与使用默认参数([expr.call])的函数调用位置相对应

请注意,“default argument()”包括默认模板参数,但上面的引号仅表示“函数调用的位置”。在默认模板参数的上下文中计算
source\u location::current()
是否合法

考虑以下代码():

#包括
//#包括
#包括
//使用source\u location=std::source\u location;
使用源位置=标准::实验::源位置;
结构文字{
char data[64]={'\0'};//为了简单起见,假设它足够大,可以容纳所有可能的值。
constexpr literal(const char*src){
char*dst=&数据[0];
而(*src)*(dst++)=*(src++);
*dst='\0';
}
};
结构位置{//由于源位置不是结构类型,因此需要结构类型。
文字文件;
文字功能;
无符号线;
无符号列;
constexpr位置(const char*文件、const char*func、无符号行、无符号列)
:file(file)、func(func)、line(line)、column(column){
constexpr位置(const source_位置和loc)
:位置(loc.file_name()、loc.function_name()、loc.line()、loc.column()){
};
模板//第30行
作废打印(){

标准没有这样说,这也是有充分理由的。没有“模板调用点”这样的东西。有一种东西叫做“模板实例化点”,但它们是(1)不明显的和(2)不一定对应于明确提到的模板。默认的非类型模板参数确实在[dcl.fct.default]中有语法描述,但这并不意味着它们是“默认参数”。我也不确定能够在行号上输入是否明智。