diff --git a/include/Orange/Core/Traits.h b/include/Orange/Core/Traits.h index 2c87511..ec4ff5f 100644 --- a/include/Orange/Core/Traits.h +++ b/include/Orange/Core/Traits.h @@ -170,7 +170,7 @@ namespace orange namespace Util { template - OutputIt Transform(InputIt inFirst, InputIt inLast, + constexpr OutputIt Transform(InputIt inFirst, InputIt inLast, OutputIt outFirst, UnaryOperation unaryOp) { while (inFirst != inLast) @@ -179,7 +179,7 @@ namespace orange } template - OutputIt Transform(InputIt1 first1, InputIt1 last1, InputIt2 first2, + constexpr OutputIt Transform(InputIt1 first1, InputIt1 last1, InputIt2 first2, OutputIt outFirst, BinaryOperation binOp) { while (first1 != last1) @@ -188,7 +188,7 @@ namespace orange } template - T TransformResult(InputIt first, InputIt last, UnaryOperation op) + constexpr T TransformResult(InputIt first, InputIt last, UnaryOperation op) { T result; Transform(first, last, result.begin(), op); @@ -196,7 +196,7 @@ namespace orange } template - T TransformResult(InputIt1 first1, InputIt1 last1, InputIt2 first2, BinaryOperation op) + constexpr T TransformResult(InputIt1 first1, InputIt1 last1, InputIt2 first2, BinaryOperation op) { T result; Transform(first1, last1, first2, result.begin(), op); @@ -221,7 +221,7 @@ namespace orange } template - bool Equal(InputIt1 first1, InputIt1 last1, InputIt2 first2) + constexpr bool Equal(InputIt1 first1, InputIt1 last1, InputIt2 first2) { for (; first1 != last1; ++first1, ++first2) { @@ -232,7 +232,7 @@ namespace orange } template - bool Equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, BinaryPredicate p) + constexpr bool Equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, BinaryPredicate p) { for (; first1 != last1; ++first1, ++first2) { @@ -243,7 +243,7 @@ namespace orange } template - OutputIt Copy(InputIt first, InputIt last, OutputIt d_first) + constexpr OutputIt Copy(InputIt first, InputIt last, OutputIt d_first) { for (; first != last; (void)++first, (void)++d_first) *d_first = *first; @@ -251,7 +251,7 @@ namespace orange } template - OutputIt CopyIf(InputIt first, InputIt last, + constexpr OutputIt CopyIf(InputIt first, InputIt last, OutputIt d_first, UnaryPredicate pred) { for (; first != last; ++first) @@ -266,7 +266,7 @@ namespace orange } template - void Fill(ForwardIt first, ForwardIt last, const T& value) + constexpr void Fill(ForwardIt first, ForwardIt last, const T& value) { for (; first != last; ++first) *first = value; @@ -275,12 +275,12 @@ namespace orange // Math ops namespace Math { - template T Negate(const T& x) { return -x; } + template constexpr T Negate(const T& x) { return -x; } - template T Add (const T& x, const T& y) { return x + y; } - template T Subtract (const T& x, const T& y) { return x - y; } - template T Multiply (const T& x, const T& y) { return x * y; } - template T Divide (const T& x, const T& y) { return x / y; } - template T Modulo (const T& x, const T& y) { return x % y; } + template constexpr T Add (const T& x, const T& y) { return x + y; } + template constexpr T Subtract (const T& x, const T& y) { return x - y; } + template constexpr T Multiply (const T& x, const T& y) { return x * y; } + template constexpr T Divide (const T& x, const T& y) { return x / y; } + template constexpr T Modulo (const T& x, const T& y) { return x % y; } } }