Advertisement
Radfler

::source_location

Mar 8th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. struct source_location {
  2.  
  3. public:
  4.  
  5.     constexpr source_location(int line, const char* file, const char* function) noexcept
  6.         : this_line(line), this_file(file), this_function(function) { }
  7.  
  8.     constexpr int line() const noexcept {
  9.         return this_line;
  10.     }
  11.  
  12.     constexpr const char* file() const noexcept {
  13.         return this_file;
  14.     }
  15.  
  16.     constexpr const char* function() const noexcept {
  17.         return this_function;
  18.     }
  19.  
  20. private:
  21.  
  22.     const int this_line;
  23.     const char* const this_file;
  24.     const char* const this_function;
  25.  
  26. };
  27.  
  28. #define SOURCE_LOCATION (::source_location(__LINE__, __FILE__, "outside a function"))
  29. #define SOURCE_LOCATION_FN (::source_location(__LINE__, __FILE__, __func__))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement