Skip to content

Commit d4ebef2

Browse files
committed
Rename xtd::helpers::strictly_ordered to xtd::comparable
1 parent c1ae5f1 commit d4ebef2

File tree

12 files changed

+187
-194
lines changed

12 files changed

+187
-194
lines changed

examples/xtd.core.examples/generic_collections/generic_enumerable_generator/src/generic_enumerable_generator.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ auto odd_numbers_generator(int count = 100, int min_value = 0, int max_value = 1
88

99
auto main() -> int {
1010
println("Odd numbers : ");
11-
auto odd_numbers = odd_numbers_generator()
12-
.where([](auto n) {return n % 5 == 0;})
13-
.distinct();
14-
for (auto number : odd_numbers)
11+
for (auto number : odd_numbers_generator().where([](auto n) {return n % 5 == 0;}).distinct())
1512
println("{,4}", number);
1613
println("Done!");
1714
}

src/xtd.core/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ add_sources(
123123
"include/xtd/chrono"
124124
"include/xtd/cnull.hpp"
125125
"include/xtd/cnull"
126+
"include/xtd/comparable.hpp"
127+
"include/xtd/comparable"
126128
"include/xtd/comparison.hpp"
127129
"include/xtd/comparison"
128130
"include/xtd/compiler.hpp"
@@ -844,8 +846,6 @@ add_sources(
844846
"include/xtd/helpers/greater_than_comparable"
845847
"include/xtd/helpers/less_than_comparable.hpp"
846848
"include/xtd/helpers/less_than_comparable"
847-
"include/xtd/helpers/strictly_ordered.hpp"
848-
"include/xtd/helpers/strictly_ordered"
849849
"include/xtd/helpers/throw_helper.hpp"
850850
"include/xtd/helpers/throw_helper"
851851
"include/xtd/extensions/comparison_operators.hpp"

src/xtd.core/include/xtd/collections/generic/comparer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ namespace xtd {
6464
/// | Zero | x equals y. |
6565
/// | Greater than zero | x is greater than y. |
6666
[[nodiscard]] auto compare(const first_argument_type& x, const second_argument_type& y) const -> result_type override {
67-
if constexpr(xtd::helpers::strictly_ordered<first_argument_type> || std::derived_from<first_argument_type, xtd::icomparable<first_argument_type>>) return helpers::comparer<type_t> {}(x, y);
67+
if constexpr(xtd::comparable<first_argument_type> || std::derived_from<first_argument_type, xtd::icomparable<first_argument_type>>) return helpers::comparer<type_t> {}(x, y);
6868
else xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_operation, "Failed to compare two elements in the array.");
6969
}
7070

src/xtd.core/include/xtd/collections/generic/helpers/comparer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
/// @copyright Copyright (c) 2026 Gammasoft. All rights reserved.
44
#pragma once
55
#include "../icomparer.hpp"
6+
#include "../../../comparable.hpp"
67
#include "../../../icomparable.hpp"
78
#include "../../../int32.hpp"
8-
#include "../../../helpers/strictly_ordered.hpp"
99

1010
/// @brief The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
1111
namespace xtd {
@@ -68,7 +68,7 @@ namespace xtd {
6868
if (&x == &y) return 0;
6969
if (comparer_) return comparer_->compare(x, y);
7070
if constexpr(std::is_polymorphic_v<first_argument_type> && std::is_base_of_v<xtd::icomparable<first_argument_type>, first_argument_type>) return static_cast<const xtd::icomparable<first_argument_type>&>(x).compare_to(y);
71-
else if constexpr(xtd::helpers::strictly_ordered<first_argument_type>) return x < y ? -1 : (x > y ? 1 : 0);
71+
else if constexpr(xtd::comparable<first_argument_type>) return x < y ? -1 : (x > y ? 1 : 0);
7272
else return &x < &y ? -1 : 1;
7373
}
7474
/// @}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#pragma once
2+
#include <xtd/comparable.hpp>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/// @file
2+
/// @brief Contains xtd::comparable concept.
3+
/// @copyright Copyright (c) 2026 Gammasoft. All rights reserved.
4+
#pragma once
5+
#include "helpers/greater_than_comparable.hpp"
6+
#include "helpers/less_than_comparable.hpp"
7+
8+
/// @brief The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
9+
namespace xtd {
10+
/// @brief Concept comparable.
11+
/// @par Definition
12+
/// ```cpp
13+
/// template<typename value_t>
14+
/// concept comparable;
15+
/// ```
16+
/// @par Header
17+
/// ```cpp
18+
/// #include <xtd/comparable>
19+
/// ```
20+
/// @par Namespace
21+
/// xtd
22+
/// @par Library
23+
/// xtd.core
24+
/// @ingroup xtd_core concepts
25+
template<typename value_t>
26+
concept comparable = xtd::helpers::less_than_comparable<value_t> && xtd::helpers::greater_than_comparable<value_t>;
27+
}

src/xtd.core/include/xtd/helpers/strictly_ordered

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/xtd.core/include/xtd/helpers/strictly_ordered.hpp

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/xtd.core/include/xtd/xtd.core.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
#include "helpers/exception_case.hpp"
113113
#include "helpers/greater_than_comparable.hpp"
114114
#include "helpers/less_than_comparable.hpp"
115-
#include "helpers/strictly_ordered.hpp"
116115
#include "helpers/throw_helper.hpp"
117116
#include "io/binary_reader.hpp"
118117
#include "io/binary_writer.hpp"
@@ -339,6 +338,8 @@
339338
#include "char8_object.hpp"
340339
#include "char_object.hpp"
341340
#include "cnull.hpp"
341+
#include "comparable.hpp"
342+
#include "comparison.hpp"
342343
#include "compiler.hpp"
343344
#include "compiler_id.hpp"
344345
#include "console.hpp"

tests/xtd.core.unit_tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ add_sources(
4040
"src/xtd/globalization/tests/translator_tests.cpp"
4141
"src/xtd/helpers/tests/exception_case_tests.cpp"
4242
"src/xtd/helpers/tests/greater_than_comparable_tests.cpp"
43-
"src/xtd/helpers/tests/strictly_ordered_tests.cpp"
4443
"src/xtd/helpers/tests/less_than_comparable_tests.cpp"
4544
"src/xtd/io/tests/binary_reader_tests.cpp"
4645
"src/xtd/io/tests/directory_tests.cpp"
@@ -137,6 +136,7 @@ add_sources(
137136
"src/xtd/tests/build_type.hpp"
138137
"src/xtd/tests/build_type_tests.cpp"
139138
"src/xtd/tests/bytes_assert.hpp"
139+
"src/xtd/tests/comparable_tests.cpp"
140140
"src/xtd/tests/compiler_name.hpp"
141141
"src/xtd/tests/compiler_tests.cpp"
142142
"src/xtd/tests/compiler_id_tests.cpp"

0 commit comments

Comments
 (0)