Skip to content

Commit fe7cd0a

Browse files
committed
Fix build breaks from first impl
1 parent bedd5b8 commit fe7cd0a

File tree

2 files changed

+46
-50
lines changed

2 files changed

+46
-50
lines changed

strings/base_macros.h

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,50 @@ typedef struct _GUID GUID;
8686
// release binaries, or to reduce binary size. Defining WINRT_NO_SOURCE_LOCATION will prevent this feature from activating.
8787
#if defined(__cpp_lib_source_location) && !defined(WINRT_NO_SOURCE_LOCATION)
8888

89+
namespace winrt::impl
90+
{
91+
// This struct is intended to be highly similar to std::source_location. The key difference is
92+
// that function_name is NOT included. Function names do not fold to identical strings and can
93+
// have heavy binary size overhead when templates cause many permutations to exist.
94+
struct slim_source_location
95+
{
96+
[[nodiscard]] static consteval slim_source_location current(
97+
const std::uint_least32_t line = __builtin_LINE(),
98+
const char* const file = __builtin_FILE()) noexcept
99+
{
100+
return slim_source_location{ line, file };
101+
}
102+
103+
[[nodiscard]] constexpr slim_source_location() noexcept = default;
104+
105+
[[nodiscard]] constexpr slim_source_location(const std::uint_least32_t line,
106+
const char* const file) noexcept :
107+
m_line(line),
108+
m_file(file)
109+
{}
110+
111+
[[nodiscard]] constexpr std::uint_least32_t line() const noexcept
112+
{
113+
return m_line;
114+
}
115+
116+
[[nodiscard]] constexpr const char* file_name() const noexcept
117+
{
118+
return m_file;
119+
}
120+
121+
constexpr const char* function_name() const noexcept
122+
{
123+
// This is intentionally not included. See comment above.
124+
return nullptr;
125+
}
126+
127+
private:
128+
const std::uint_least32_t m_line{};
129+
const char* const m_file{};
130+
};
131+
}
132+
89133
// std::source_location includes function_name which can be helpful but creates a lot of binary size impact. Many consumers
90134
// have defined WINRT_NO_SOURCE_LOCATION to prevent this impact, losing the value of source_location. We have defined a
91135
// slim_source_location struct that is equivalent but excludes function_name. This should have the vast majority of the
@@ -122,8 +166,6 @@ typedef struct _GUID GUID;
122166

123167
#endif // _DEBUG
124168

125-
126-
#endif
127169
#else
128170
#define WINRT_IMPL_SOURCE_LOCATION_ARGS_NO_DEFAULT
129171
#define WINRT_IMPL_SOURCE_LOCATION_ARGS
@@ -134,5 +176,5 @@ typedef struct _GUID GUID;
134176

135177
#ifdef _MSC_VER
136178
#pragma detect_mismatch("WINRT_SOURCE_LOCATION", "false")
137-
#endif
138-
#endif
179+
#endif // _MSC_VER
180+
#endif // defined(__cpp_lib_source_location) && !defined(WINRT_NO_SOURCE_LOCATION)

strings/base_types.h

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -247,49 +247,3 @@ namespace winrt::impl
247247
inline constexpr hresult error_not_initialized{ static_cast<hresult>(0x800401F0) }; // CO_E_NOTINITIALIZED
248248
inline constexpr hresult error_file_not_found{ static_cast<hresult>(0x80070002) }; // HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)
249249
}
250-
251-
#if defined(__cpp_lib_source_location) && !defined(WINRT_NO_SOURCE_LOCATION)
252-
namespace winrt::impl
253-
{
254-
// This struct is intended to be highly similar to std::source_location. The key difference is
255-
// that function_name is NOT included. Function names do not fold to identical strings and can
256-
// have heavy binary size overhead when templates cause many permutations to exist.
257-
struct slim_source_location
258-
{
259-
[[nodiscard]] static consteval slim_source_location current(
260-
const std::uint_least32_t line = __builtin_LINE(),
261-
const char* const file = __builtin_FILE()) noexcept
262-
{
263-
return slim_source_location{ line, fille };
264-
}
265-
266-
[[nodiscard]] constexpr slim_source_location() noexcept = default;
267-
268-
[[nodiscard]] constexpr slim_source_location(const std::uint_least32_t line,
269-
const char* const file) noexcept :
270-
m_line(line),
271-
m_file(file)
272-
{}
273-
274-
[[nodiscard]] constexpr std::uint_least32_t line() const noexcept
275-
{
276-
return m_line;
277-
}
278-
279-
[[nodiscard]] constexpr const char* file_name() const noexcept
280-
{
281-
return m_file;
282-
}
283-
284-
constexpr const char* function_name() const noexcept
285-
{
286-
// This is intentionally not included. See comment above.
287-
return nullptr;
288-
}
289-
290-
private:
291-
const std::uint_least32_t m_line{};
292-
const char* const m_file{};
293-
};
294-
}
295-
#endif defined(__cpp_lib_source_location) && !defined(WINRT_NO_SOURCE_LOCATION)

0 commit comments

Comments
 (0)