Skip to content

Commit 84f0f73

Browse files
committed
fix build
1 parent 73117f1 commit 84f0f73

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/r4/vector.hpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ SOFTWARE.
2828

2929
#include <array>
3030

31+
#include <utki/config.hpp>
3132
#include <utki/debug.hpp>
3233
#include <utki/math.hpp>
3334

@@ -674,7 +675,10 @@ class vector :
674675
* @param num - scalar to multiply by.
675676
* @return Reference to this vector object.
676677
*/
677-
constexpr vector& operator*=(component_type num) noexcept
678+
#if CFG_CPP >= 20
679+
constexpr
680+
#endif
681+
vector& operator*=(component_type num) noexcept
678682
{
679683
return this->comp_operation([&num](auto& a) {
680684
return a * num;
@@ -687,7 +691,10 @@ class vector :
687691
* @param num - scalar to multiply by.
688692
* @return Vector resulting from multiplication of this vector by scalar.
689693
*/
690-
constexpr vector operator*(component_type num) const noexcept
694+
#if CFG_CPP >= 20
695+
constexpr
696+
#endif
697+
vector operator*(component_type num) const noexcept
691698
{
692699
return (vector(*this) *= num);
693700
}
@@ -698,7 +705,10 @@ class vector :
698705
* @param num - scalar to divide by.
699706
* @return Vector resulting from division of this vector by scalar.
700707
*/
701-
constexpr vector operator/(component_type num) const noexcept
708+
#if CFG_CPP >= 20
709+
constexpr
710+
#endif
711+
vector operator/(component_type num) const noexcept
702712
{
703713
return vector(*this) /= num;
704714
}
@@ -720,7 +730,10 @@ class vector :
720730
* @param num - scalar to divide by.
721731
* @return Reference to this vector object.
722732
*/
723-
constexpr vector& operator/=(component_type num) noexcept
733+
#if CFG_CPP >= 20
734+
constexpr
735+
#endif
736+
vector& operator/=(component_type num) noexcept
724737
{
725738
// TODO: uncomment when there is a solution to have the assertion in constexpr context
726739
// utki::assert(num != 0, [&](auto& o) {

tests/unit/src/vector4.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <tst/set.hpp>
22
#include <tst/check.hpp>
33

4+
#include <utki/config.hpp>
45
#include <utki/string.hpp>
56

67
#include "../../../src/r4/vector.hpp"
@@ -536,17 +537,21 @@ const tst::set set("vector4", [](tst::suite& suite){
536537
});
537538

538539
suite.add("constexprness", [](){
540+
#if CFG_CPP >= 20
539541
// operator/(number)
540542
{
541543
constexpr auto v = r4::vector4<unsigned>(10, 20, 30, 40) / 2;
542544
tst::check_eq(v, r4::vector4<unsigned>(10, 20, 30, 40) / 2, SL);
543545
}
546+
#endif
544547

548+
#if CFG_CPP >= 20
545549
// operator*(number)
546550
{
547551
constexpr auto v = r4::vector4<unsigned>(10, 20, 30, 40) * 2;
548552
tst::check_eq(v, r4::vector4<unsigned>(10, 20, 30, 40) * 2, SL);
549553
}
554+
#endif
550555

551556
// TODO: add other operators and functions
552557
});

0 commit comments

Comments
 (0)