feat: merge branch 'check-source-location-file-name-result'

This commit is contained in:
ToruNiina
2025-01-05 18:34:14 +09:00

View File

@@ -433,10 +433,20 @@ namespace cxx
using source_location = std::source_location;
inline std::string to_string(const source_location& loc)
{
const char* fname = loc.file_name();
if(fname)
{
return std::string(" at line ") + std::to_string(loc.line()) +
std::string(" in file ") + std::string(loc.file_name());
std::string(" in file ") + std::string(fname);
}
else
{
return std::string(" at line ") + std::to_string(loc.line()) +
std::string(" in unknown file");
}
}
} // cxx
} // toml
#elif defined(TOML11_HAS_EXPERIMENTAL_SOURCE_LOCATION)
@@ -448,10 +458,20 @@ namespace cxx
using source_location = std::experimental::source_location;
inline std::string to_string(const source_location& loc)
{
const char* fname = loc.file_name();
if(fname)
{
return std::string(" at line ") + std::to_string(loc.line()) +
std::string(" in file ") + std::string(loc.file_name());
std::string(" in file ") + std::string(fname);
}
else
{
return std::string(" at line ") + std::to_string(loc.line()) +
std::string(" in unknown file");
}
}
} // cxx
} // toml
#elif defined(TOML11_HAS_BUILTIN_FILE_LINE)
@@ -482,10 +502,20 @@ struct source_location
};
inline std::string to_string(const source_location& loc)
{
const char* fname = loc.file_name();
if(fname)
{
return std::string(" at line ") + std::to_string(loc.line()) +
std::string(" in file ") + std::string(loc.file_name());
std::string(" in file ") + std::string(fname);
}
else
{
return std::string(" at line ") + std::to_string(loc.line()) +
std::string(" in unknown file");
}
}
} // cxx
} // toml
#else // no builtin