Skip to content

Commit 8790e92

Browse files
authored
Remove the preprocessor directives used to detect C++20
1 parent a253304 commit 8790e92

File tree

5 files changed

+14
-44
lines changed

5 files changed

+14
-44
lines changed

strings/base_array.h

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ WINRT_EXPORT namespace winrt
3131
array_view(value.begin(), static_cast<size_type>(value.size()))
3232
{}
3333

34-
#ifdef __cpp_lib_span
3534
template <typename C, std::size_t extent>
3635
array_view(std::span<C, extent> span) noexcept :
3736
array_view(span.data(), static_cast<size_type>(span.size()))
@@ -43,7 +42,6 @@ WINRT_EXPORT namespace winrt
4342
{
4443
return { m_data, m_size };
4544
}
46-
#endif
4745

4846
template <typename C, size_type N>
4947
array_view(C(&value)[N]) noexcept :
@@ -237,24 +235,22 @@ WINRT_EXPORT namespace winrt
237235
template <typename C, std::size_t N> array_view(std::array<C, N>& value) -> array_view<C>;
238236
template <typename C, std::size_t N> array_view(std::array<C, N> const& value) -> array_view<C const>;
239237

240-
#ifdef __cpp_lib_span
241238
template <typename C, std::size_t extent> array_view(std::span<C, extent>& value) -> array_view<C>;
242239
template <typename C, std::size_t extent> array_view(std::span<C, extent> const& value) -> array_view<C const>;
243-
#endif
244240

245241
template <typename T>
246242
struct com_array : array_view<T>
247243
{
248-
using typename array_view<T>::value_type;
249-
using typename array_view<T>::size_type;
250-
using typename array_view<T>::reference;
251-
using typename array_view<T>::const_reference;
252-
using typename array_view<T>::pointer;
253-
using typename array_view<T>::const_pointer;
254-
using typename array_view<T>::iterator;
255-
using typename array_view<T>::const_iterator;
256-
using typename array_view<T>::reverse_iterator;
257-
using typename array_view<T>::const_reverse_iterator;
244+
using value_type = typename array_view<T>::value_type;
245+
using size_type = typename array_view<T>::size_type;
246+
using reference = typename array_view<T>::reference;
247+
using const_reference = typename array_view<T>::const_reference;
248+
using pointer = typename array_view<T>::pointer;
249+
using const_pointer = typename array_view<T>::const_pointer;
250+
using iterator = typename array_view<T>::iterator;
251+
using const_iterator = typename array_view<T>::const_iterator;
252+
using reverse_iterator = typename array_view<T>::reverse_iterator;
253+
using const_reverse_iterator = typename array_view<T>::const_reverse_iterator;
258254

259255
com_array(com_array const&) = delete;
260256
com_array& operator=(com_array const&) = delete;
@@ -293,14 +289,12 @@ WINRT_EXPORT namespace winrt
293289
com_array(value.begin(), value.end())
294290
{}
295291

296-
#ifdef __cpp_lib_span
297292
template <typename U, std::size_t extent>
298293
explicit com_array(std::span<U, extent> span) noexcept :
299294
com_array(span.data(), span.data() + span.size())
300295
{
301296
WINRT_ASSERT(span.size() <= (std::numeric_limits<size_type>::max)());
302297
}
303-
#endif
304298

305299
template <typename U, std::size_t N>
306300
explicit com_array(U const(&value)[N]) :
@@ -403,9 +397,7 @@ WINRT_EXPORT namespace winrt
403397
template <std::size_t N, typename C> com_array(C const(&)[N]) -> com_array<std::decay_t<C>>;
404398
template <typename C> com_array(std::initializer_list<C>) -> com_array<std::decay_t<C>>;
405399

406-
#ifdef __cpp_lib_span
407400
template <typename C, std::size_t extent> com_array(std::span<C, extent> const& value) -> com_array<std::decay_t<C>>;
408-
#endif
409401

410402

411403
namespace impl

strings/base_includes.h

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@
2525
#include <utility>
2626
#include <vector>
2727

28-
#if __has_include(<version>)
29-
#include <version>
30-
#endif
31-
3228
// <windowsnumerics.impl.h> pulls in large, hard-to-control legacy headers. In header builds we keep the
3329
// existing behavior, but in module builds it's provided by the winrt.numerics module.
3430
#ifndef WINRT_MODULE
@@ -43,20 +39,10 @@
4339
#include <ostream>
4440
#endif
4541

46-
#ifdef __cpp_lib_span
47-
#include <span>
48-
#endif
42+
// C++ 20 headers
4943

50-
#ifdef __cpp_lib_format
44+
#include <version>
45+
#include <span>
5146
#include <format>
52-
#endif
53-
54-
#ifdef __cpp_lib_source_location
5547
#include <source_location>
56-
#endif
57-
58-
#ifdef __cpp_lib_coroutine
5948
#include <coroutine>
60-
#else
61-
#error C++/WinRT requires coroutine support, which is currently missing. Try enabling C++20 in your compiler.
62-
#endif

strings/base_string.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ WINRT_EXPORT namespace winrt
327327
return rend();
328328
}
329329

330-
#ifdef __cpp_lib_starts_ends_with
331330
bool starts_with(wchar_t const value) const noexcept
332331
{
333332
return operator std::wstring_view().starts_with(value);
@@ -357,7 +356,6 @@ WINRT_EXPORT namespace winrt
357356
{
358357
return operator std::wstring_view().ends_with(pointer);
359358
}
360-
#endif
361359

362360
bool empty() const noexcept
363361
{
@@ -437,10 +435,8 @@ WINRT_EXPORT namespace winrt
437435
}
438436
}
439437

440-
#ifdef __cpp_lib_format
441438
template<>
442439
struct std::formatter<winrt::hstring, wchar_t> : std::formatter<std::wstring_view, wchar_t> {};
443-
#endif
444440

445441
WINRT_EXPORT namespace winrt::impl
446442
{
@@ -574,7 +570,7 @@ WINRT_EXPORT namespace winrt::impl
574570
// when non-const (e.g. ranges::filter_view) so taking a const reference
575571
// as parameter wouldn't work for all scenarios.
576572
auto const size = std::formatted_size(args...);
577-
WINRT_ASSERT(size < INT_MAX);
573+
WINRT_ASSERT(size < static_cast<std::size_t>((std::numeric_limits<std::int32_t>::max)()));
578574
auto const size32 = static_cast<std::int32_t>(size);
579575

580576
hstring_builder builder(size32);

strings/base_stringable_format.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11

2-
#ifdef __cpp_lib_format
32
template <typename FormatContext>
43
auto std::formatter<winrt::Windows::Foundation::IStringable, wchar_t>::format(winrt::Windows::Foundation::IStringable const& obj, FormatContext& fc) const
54
{
65
return std::formatter<winrt::hstring, wchar_t>::format(obj.ToString(), fc);
76
}
8-
#endif

strings/base_stringable_format_1.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11

2-
#ifdef __cpp_lib_format
32
template <>
43
struct std::formatter<winrt::Windows::Foundation::IStringable, wchar_t> : std::formatter<winrt::hstring, wchar_t>
54
{
65
template <typename FormatContext>
76
auto format(winrt::Windows::Foundation::IStringable const& obj, FormatContext& fc) const;
87
};
9-
#endif

0 commit comments

Comments
 (0)