Skip to content

Commit 7463eda

Browse files
committed
Move conditional_function to its own module
1 parent c0086ee commit 7463eda

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

source/bounded/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ target_sources(bounded PUBLIC
5858
comparison_builtin.cpp
5959
comparison_function_object.cpp
6060
concepts.cpp
61+
conditional_function.cpp
6162
constexpr_only_if.cpp
6263
construct.cpp
6364
construct_at.cpp

source/bounded/arithmetic/divides.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import bounded.arithmetic.safe_abs;
1111
import bounded.arithmetic.unary_minus;
1212
import bounded.bounded_integer;
1313
import bounded.comparison;
14+
import bounded.conditional_function;
1415
import bounded.homogeneous_equals;
1516
import bounded.integer;
1617
import bounded.minmax;
@@ -23,15 +24,6 @@ import std_module;
2324

2425
namespace bounded {
2526

26-
template<bool condition>
27-
constexpr auto conditional_function(auto if_true, auto if_false) {
28-
if constexpr (condition) {
29-
return if_true;
30-
} else {
31-
return if_false;
32-
}
33-
};
34-
3527
// Ignores divide by 0, caught by constexpr
3628
template<auto lhs, auto rhs>
3729
constexpr auto safer_divide() {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright David Stone 2024.
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// (See accompanying file LICENSE_1_0.txt or copy at
4+
// http://www.boost.org/LICENSE_1_0.txt)
5+
6+
export module bounded.conditional_function;
7+
8+
namespace bounded {
9+
10+
export template<bool condition>
11+
constexpr auto conditional_function(auto if_true, auto if_false) {
12+
if constexpr (condition) {
13+
return if_true;
14+
} else {
15+
return if_false;
16+
}
17+
};
18+
19+
} // namespace bounded

0 commit comments

Comments
 (0)