File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- 1
1+ #include < iostream>
2+ #include < string_view>
3+ #include < source_location>
4+
5+ void log (const std::string_view message,
6+ const std::source_location location =
7+ std::source_location::current ())
8+ {
9+ std::cout << " file: "
10+ << location.file_name () << " ("
11+ << location.line () << " :"
12+ << location.column () << " ) `"
13+ << location.function_name () << " `: "
14+ << message << ' \n ' ;
15+ }
16+
17+ template <typename T> void fun (T x)
18+ {
19+ log (x);
20+ }
21+
22+ int main (int , char *[])
23+ {
24+ log (" Hello world!" );
25+ fun (" Hello C++20!" );
26+ }
27+ #include < iostream>
28+ #include < string_view>
29+ #include < source_location>
30+
31+ void log (const std::string_view message,
32+ const std::source_location location =
33+ std::source_location::current ())
34+ {
35+ std::cout << " file: "
36+ << location.file_name () << " ("
37+ << location.line () << " :"
38+ << location.column () << " ) `"
39+ << location.function_name () << " `: "
40+ << message << ' \n ' ;
41+ }
42+
43+ template <typename T> void fun (T x)
44+ {
45+ log (x);
46+ }
47+
48+ int main (int , char *[])
49+ {
50+ log (" Hello world!" );
51+ fun (" Hello C++20!" );
52+ }
You can’t perform that action at this time.
0 commit comments