File tree Expand file tree Collapse file tree 3 files changed +21
-9
lines changed Expand file tree Collapse file tree 3 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ target_sources(bounded PUBLIC
58
58
comparison_builtin.cpp
59
59
comparison_function_object.cpp
60
60
concepts.cpp
61
+ conditional_function.cpp
61
62
constexpr_only_if.cpp
62
63
construct.cpp
63
64
construct_at.cpp
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import bounded.arithmetic.safe_abs;
11
11
import bounded.arithmetic.unary_minus;
12
12
import bounded.bounded_integer;
13
13
import bounded.comparison;
14
+ import bounded.conditional_function;
14
15
import bounded.homogeneous_equals;
15
16
import bounded.integer;
16
17
import bounded.minmax;
@@ -23,15 +24,6 @@ import std_module;
23
24
24
25
namespace bounded {
25
26
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
-
35
27
// Ignores divide by 0, caught by constexpr
36
28
template <auto lhs, auto rhs>
37
29
constexpr auto safer_divide () {
Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments