diff options
author | Alexander Smirnov <alex@ydb.tech> | 2024-07-08 15:54:05 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-07-08 15:54:05 +0000 |
commit | fc7be18c76af2e700641f3598c4856baeef1428e (patch) | |
tree | 11dbca45eb321c3a4dd08b12152acc6ef5dd3fa9 /library/cpp/yt/misc/source_location.h | |
parent | ec0e7ed6da6fb317741fd8468602949a1362eca5 (diff) | |
parent | c92cb9d3a19331916f0c274d80e67f02a62caa9b (diff) | |
download | ydb-fc7be18c76af2e700641f3598c4856baeef1428e.tar.gz |
Merge branch 'rightlib' into mergelibs-240708-1553
Diffstat (limited to 'library/cpp/yt/misc/source_location.h')
-rw-r--r-- | library/cpp/yt/misc/source_location.h | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/library/cpp/yt/misc/source_location.h b/library/cpp/yt/misc/source_location.h index 0496a4e496..286527887a 100644 --- a/library/cpp/yt/misc/source_location.h +++ b/library/cpp/yt/misc/source_location.h @@ -14,9 +14,7 @@ class TStringBuilderBase; // TODO(dgolear): Drop when LLVM-14 is eradicated. #ifdef __cpp_lib_source_location - void FormatValue(TStringBuilderBase* builder, const std::source_location& location, TStringBuf /*spec*/); - #endif // __cpp_lib_source_location //////////////////////////////////////////////////////////////////////////////// @@ -24,15 +22,11 @@ void FormatValue(TStringBuilderBase* builder, const std::source_location& locati class TSourceLocation { public: - TSourceLocation() - : FileName_(nullptr) - , Line_(-1) - { } - - TSourceLocation(const char* fileName, int line) - : FileName_(fileName) - , Line_(line) - { } + TSourceLocation() = default; + TSourceLocation(const char* fileName, int line); +#ifdef __cpp_lib_source_location + explicit TSourceLocation(const std::source_location& location); +#endif // __cpp_lib_source_location const char* GetFileName() const; int GetLine() const; @@ -41,21 +35,16 @@ public: bool operator<(const TSourceLocation& other) const; bool operator==(const TSourceLocation& other) const; -#ifdef __cpp_lib_source_location - static TSourceLocation FromStd(const std::source_location& location); -#endif // __cpp_lib_source_location - private: - const char* FileName_; - int Line_; - + const char* FileName_ = nullptr; + int Line_ = -1; }; //! Defines a macro to record the current source location. #ifdef __cpp_lib_source_location -#define FROM_HERE ::NYT::TSourceLocation::FromStd(std::source_location::current()) +#define YT_CURRENT_SOURCE_LOCATION ::NYT::TSourceLocation(std::source_location::current()) #else -#define FROM_HERE ::NYT::TSourceLocation(__FILE__, __LINE__) +#define YT_CURRENT_SOURCE_LOCATION ::NYT::TSourceLocation(__FILE__, __LINE__) #endif // __cpp_lib_source_location void FormatValue(TStringBuilderBase* builder, const TSourceLocation& location, TStringBuf spec); @@ -63,3 +52,7 @@ void FormatValue(TStringBuilderBase* builder, const TSourceLocation& location, T //////////////////////////////////////////////////////////////////////////////// } // namespace NYT + +#define SOURCE_LOCATION_INL_H_ +#include "source_location-inl.h" +#undef SOURCE_LOCATION_INL_H_ |