Skip to content

Commit b043ee4

Browse files
author
Tim Ebbeke
committed
interval constructor is now constexpr
1 parent f5bff66 commit b043ee4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

interval_tree.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,19 @@ namespace lib_interval_tree
3737
* Constructs an interval. low MUST be smaller than high.
3838
*/
3939
#ifndef INTERVAL_TREE_SAFE_INTERVALS
40+
#if __cplusplus >= 201703L
41+
constexpr
42+
#endif
4043
interval(value_type low, value_type high)
4144
: low_{low}
4245
, high_{high}
4346
{
4447
assert(low <= high);
4548
}
4649
#else
50+
#if __cplusplus >= 201703L
51+
constexpr
52+
#endif
4753
interval(value_type low, value_type high)
4854
: low_{std::min(low, high)}
4955
, high_{std::max(low, high)}
@@ -173,6 +179,9 @@ namespace lib_interval_tree
173179
* Creates a safe interval that puts the lower bound left automatically.
174180
*/
175181
template <typename numerical_type, typename interval_kind_ = closed>
182+
#if __cplusplus >= 201703L
183+
constexpr
184+
#endif
176185
interval <numerical_type, interval_kind_> make_safe_interval(numerical_type lhs, numerical_type rhs)
177186
{
178187
return interval <numerical_type, interval_kind_>{std::min(lhs, rhs), std::max(lhs, rhs)};

0 commit comments

Comments
 (0)