|
13 | 13 |
|
14 | 14 | #include <hpx/config/export_definitions.hpp> |
15 | 15 |
|
16 | | -#include <cstdint> |
17 | 16 | #include <iosfwd> |
18 | | - |
19 | | -#if defined(HPX_HAVE_CXX20_SOURCE_LOCATION) |
20 | 17 | #include <source_location> |
21 | | -#endif |
22 | 18 |
|
23 | 19 | namespace hpx { |
24 | 20 |
|
25 | 21 | /// This contains the location information where \a HPX_ASSERT has been |
26 | 22 | /// called |
27 | | -#if defined(HPX_HAVE_CXX20_SOURCE_LOCATION) |
28 | 23 | HPX_CXX_CORE_EXPORT using std::source_location; |
29 | | -#else |
30 | | - /// The \a source_location class represents certain information about the |
31 | | - /// source code, such as file names, line numbers, and function names. |
32 | | - /// Previously, functions that desire to obtain this information about |
33 | | - /// the call site (for logging, testing, or debugging purposes) must |
34 | | - /// use macros so that predefined macros like \a __LINE__ and \a __FILE__ |
35 | | - /// are expanded in the context of the caller. The \a source_location class |
36 | | - /// provides a better alternative. |
37 | | - /// \a source_location meets the \a DefaultConstructible, \a CopyConstructible, |
38 | | - /// \a CopyAssignable and \a Destructible requirements. Lvalue of \a |
39 | | - /// source_location meets the Swappable requirement. Additionally, the following |
40 | | - /// conditions are true: |
41 | | - /// - \code std::is_nothrow_move_constructible_v<std::source_location> \endcode |
42 | | - /// - \code std::is_nothrow_move_assignable_v<std::source_location> \endcode |
43 | | - /// - \code std::is_nothrow_swappable_v<std::source_location> \endcode |
44 | | - /// It is intended that source_location has a small size and can be copied |
45 | | - /// efficiently. |
46 | | - /// It is unspecified whether the copy/move constructors and the copy/move |
47 | | - /// assignment operators of \a source_location are trivial and/or constexpr. |
48 | | - HPX_CXX_CORE_EXPORT struct source_location |
49 | | - { |
50 | | - char const* filename; |
51 | | - std::uint_least32_t line_number; |
52 | | - char const* functionname; |
53 | | - |
54 | | - // compatibility with C++20 std::source_location |
55 | | - /// return the line number represented by this object |
56 | | - [[nodiscard]] constexpr std::uint_least32_t line() const noexcept |
57 | | - { |
58 | | - return line_number; |
59 | | - } |
60 | | - |
61 | | - /// return the column number represented by this object |
62 | | - [[nodiscard]] static constexpr std::uint_least32_t column() noexcept |
63 | | - { |
64 | | - return 0; |
65 | | - } |
66 | | - |
67 | | - /// return the file name represented by this object |
68 | | - [[nodiscard]] constexpr char const* file_name() const noexcept |
69 | | - { |
70 | | - return filename; |
71 | | - } |
72 | | - |
73 | | - /// return the name of the function represented by this object, if any |
74 | | - [[nodiscard]] constexpr char const* function_name() const noexcept |
75 | | - { |
76 | | - return functionname; |
77 | | - } |
78 | | - }; |
79 | | -#endif |
80 | 24 |
|
81 | 25 | HPX_CXX_CORE_EXPORT HPX_CORE_EXPORT std::ostream& operator<<( |
82 | 26 | std::ostream& os, source_location const& loc); |
|
0 commit comments