@@ -429,7 +429,7 @@ class vector :
429429 * @return Reference to this vector.
430430 */
431431 template <typename unary_operation_type>
432- vector& comp_operation (unary_operation_type op)
432+ constexpr vector& comp_operation (unary_operation_type op)
433433 {
434434 std::transform (
435435 this ->begin (), //
@@ -449,9 +449,18 @@ class vector :
449449 * @return Reference to this vector.
450450 */
451451 template <typename binary_operation_type>
452- vector& comp_operation (const vector& vec, binary_operation_type op)
452+ constexpr vector& comp_operation (
453+ const vector& vec, //
454+ binary_operation_type op
455+ )
453456 {
454- std::transform (this ->begin (), this ->end (), vec.begin (), this ->begin (), op);
457+ std::transform (
458+ this ->begin (), //
459+ this ->end (),
460+ vec.begin (),
461+ this ->begin (),
462+ op
463+ );
455464 return *this ;
456465 }
457466
@@ -689,7 +698,7 @@ class vector :
689698 * @param num - scalar to divide by.
690699 * @return Vector resulting from division of this vector by scalar.
691700 */
692- vector operator /(component_type num) const noexcept
701+ constexpr vector operator /(component_type num) const noexcept
693702 {
694703 return vector (*this ) /= num;
695704 }
@@ -711,11 +720,12 @@ class vector :
711720 * @param num - scalar to divide by.
712721 * @return Reference to this vector object.
713722 */
714- vector& operator /=(component_type num) noexcept
723+ constexpr vector& operator /=(component_type num) noexcept
715724 {
716- ASSERT (num != 0 , [&](auto & o) {
717- o << " vector::operator/=(): division by 0" ;
718- })
725+ // TODO: uncomment when there is a solution to have the assertion in constexpr context
726+ // utki::assert(num != 0, [&](auto& o) {
727+ // o << "vector::operator/=(): division by 0";
728+ // });
719729 return this ->comp_operation ([&num](auto & a) {
720730 return a / num;
721731 });
0 commit comments