From d48b6fcc2748e86e4dae842458869fed19d8347f Mon Sep 17 00:00:00 2001 From: Morwenn Date: Sun, 7 Jan 2024 21:20:31 +0100 Subject: [PATCH] constexpr drop_merge_adapter (#58) --- include/cpp-sort/adapters/drop_merge_adapter.h | 6 +++--- include/cpp-sort/detail/drop_merge_sort.h | 6 +++--- tests/adapters/every_adapter_constexpr.cpp | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/cpp-sort/adapters/drop_merge_adapter.h b/include/cpp-sort/adapters/drop_merge_adapter.h index 4afd5639..2a66304c 100644 --- a/include/cpp-sort/adapters/drop_merge_adapter.h +++ b/include/cpp-sort/adapters/drop_merge_adapter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Morwenn + * Copyright (c) 2022-2024 Morwenn * SPDX-License-Identifier: MIT */ #ifndef CPPSORT_ADAPTERS_DROP_MERGE_ADAPTER_H_ @@ -42,8 +42,8 @@ namespace cppsort typename Projection = std::identity > requires is_projection_iterator_v - auto operator()(Iterator first, Sentinel last, - Compare compare={}, Projection projection={}) const + constexpr auto operator()(Iterator first, Sentinel last, + Compare compare={}, Projection projection={}) const -> Iterator { return drop_merge_sort(std::move(first), std::move(last), diff --git a/include/cpp-sort/detail/drop_merge_sort.h b/include/cpp-sort/detail/drop_merge_sort.h index 0d5d7f5a..36f07741 100644 --- a/include/cpp-sort/detail/drop_merge_sort.h +++ b/include/cpp-sort/detail/drop_merge_sort.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2022 Morwenn + * Copyright (c) 2017-2024 Morwenn * SPDX-License-Identifier: MIT */ @@ -44,8 +44,8 @@ namespace cppsort::detail typename Projection, typename Sorter > - auto drop_merge_sort(BidirectionalIterator first, Sentinel last, - Compare compare, Projection projection, Sorter&& sorter) + constexpr auto drop_merge_sort(BidirectionalIterator first, Sentinel last, + Compare compare, Projection projection, Sorter&& sorter) -> BidirectionalIterator { using difference_type = mstd::iter_difference_t; diff --git a/tests/adapters/every_adapter_constexpr.cpp b/tests/adapters/every_adapter_constexpr.cpp index d7e733c5..1db69433 100644 --- a/tests/adapters/every_adapter_constexpr.cpp +++ b/tests/adapters/every_adapter_constexpr.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Morwenn + * Copyright (c) 2022-2024 Morwenn * SPDX-License-Identifier: MIT */ #include @@ -28,7 +28,8 @@ namespace } TEMPLATE_TEST_CASE( "test most adapters in a constexpr context", "[adapters][constexpr]", - cppsort::hybrid_adapter ) + cppsort::hybrid_adapter, + cppsort::drop_merge_adapter ) { constexpr bool is_sorted = test_constexpr_sorter(); STATIC_CHECK( is_sorted );