2 // NOTE: source_location.cpp must include this file after defining
3 // std::source_location.
4 namespace source_location_file
{
6 constexpr const char *FILE = __FILE__
;
7 constexpr const char *FILE_NAME
= __FILE_NAME__
;
9 constexpr SL global_info
= SL::current();
10 constexpr const char *global_info_filename
= __builtin_FILE_NAME();
12 constexpr SL
test_function(SL v
= SL::current()) {
16 constexpr SL
test_function_indirect() {
17 return test_function();
20 constexpr const char *test_function_filename(
21 const char *file_name
= __builtin_FILE_NAME()) {
25 constexpr const char *test_function_filename_indirect() {
26 return test_function_filename();
29 template <class T
, class U
= SL
>
30 constexpr U
test_function_template(T
, U u
= U::current()) {
34 template <class T
, class U
= SL
>
35 constexpr U
test_function_template_indirect(T t
) {
36 return test_function_template(t
);
39 template <class T
, class U
= const char *>
40 constexpr U
test_function_filename_template(T
, U u
= __builtin_FILE_NAME()) {
44 template <class T
, class U
= const char *>
45 constexpr U
test_function_filename_template_indirect(T t
) {
46 return test_function_filename_template(t
);
50 SL info
= SL::current();
51 const char *info_file_name
= __builtin_FILE_NAME();
53 const char *ctor_info_file_name
= nullptr;
54 TestClass() = default;
55 constexpr TestClass(int, SL cinfo
= SL::current(),
56 const char *cfile_name
= __builtin_FILE_NAME()) :
57 ctor_info(cinfo
), ctor_info_file_name(cfile_name
) {}
58 template <class T
, class U
= SL
>
59 constexpr TestClass(int, T
, U u
= U::current(),
60 const char *cfile_name
= __builtin_FILE_NAME()) :
61 ctor_info(u
), ctor_info_file_name(cfile_name
) {}
64 template <class T
= SL
>
68 T init_info
= T::current();
69 const char *init_info_file_name
= __builtin_FILE_NAME();
72 } // namespace source_location_file