|
@@ -268,8 +268,19 @@ namespace simple::geom
|
|
|
&& !std::is_same<Another, vector>::value
|
|
|
&& !std::is_base_of<vector, Another>::value
|
|
|
&& std::is_convertible<typename Another::coordinate_type, Coordinate>::value
|
|
|
+ && std::is_constructible<Coordinate, typename Another::coordinate_type>::value
|
|
|
>* = nullptr>
|
|
|
- struct is_convertible_to_me {};
|
|
|
+ struct is_implicitly_convertible_to_me {};
|
|
|
+
|
|
|
+ template <typename Another, std::enable_if_t<
|
|
|
+ Another::dimensions == Dimensions
|
|
|
+ && !std::is_same<Another, vector>::value
|
|
|
+ && !std::is_base_of<vector, Another>::value
|
|
|
+ && !std::is_convertible<typename Another::coordinate_type, Coordinate>::value
|
|
|
+ // TODO: this does not cover aggregates and enums
|
|
|
+ && std::is_constructible<Coordinate, typename Another::coordinate_type>::value
|
|
|
+ >* = nullptr>
|
|
|
+ struct is_explicitly_convertible_to_me {};
|
|
|
|
|
|
template <typename Another, size_t dimension = Dimensions - 1>
|
|
|
constexpr void set_in_order(const Another& another)
|
|
@@ -290,24 +301,40 @@ namespace simple::geom
|
|
|
: raw {std::forward<Coordinates>(coordinates)...}
|
|
|
{}
|
|
|
|
|
|
- // TODO: since operators follow promotion rules of underlying type now, it might be more sensible to make construction/conversions do that too
|
|
|
- // TODO: constexpr and forwarding
|
|
|
- template <typename Another, is_convertible_to_me<Another>* = nullptr,
|
|
|
+ // TODO: forwarding
|
|
|
+ template <typename Another, is_explicitly_convertible_to_me<Another>* = nullptr,
|
|
|
std::enable_if_t<std::is_same_v<typename Another::order, Order>> *...>
|
|
|
constexpr explicit vector(const Another& another) : raw{}
|
|
|
{
|
|
|
for(size_t i = 0; i < Dimensions; ++i)
|
|
|
- raw[i] = another[i];
|
|
|
+ raw[i] = Coordinate(another[i]);
|
|
|
}
|
|
|
|
|
|
// TODO: forwarding
|
|
|
- template <typename Another, is_convertible_to_me<Another>* = nullptr,
|
|
|
+ template <typename Another, is_explicitly_convertible_to_me<Another>* = nullptr,
|
|
|
std::enable_if_t<!std::is_same_v<typename Another::order, Order>> *...>
|
|
|
constexpr explicit vector(const Another& another) : raw{}
|
|
|
{
|
|
|
set_in_order<Another>(another);
|
|
|
}
|
|
|
|
|
|
+ // TODO: forwarding
|
|
|
+ template <typename Another, is_implicitly_convertible_to_me<Another>* = nullptr,
|
|
|
+ std::enable_if_t<std::is_same_v<typename Another::order, Order>> *...>
|
|
|
+ constexpr vector(const Another& another) : raw{}
|
|
|
+ {
|
|
|
+ for(size_t i = 0; i < Dimensions; ++i)
|
|
|
+ raw[i] = another[i];
|
|
|
+ }
|
|
|
+
|
|
|
+ // TODO: forwarding
|
|
|
+ template <typename Another, is_implicitly_convertible_to_me<Another>* = nullptr,
|
|
|
+ std::enable_if_t<!std::is_same_v<typename Another::order, Order>> *...>
|
|
|
+ constexpr vector(const Another& another) : raw{}
|
|
|
+ {
|
|
|
+ set_in_order<Another>(another);
|
|
|
+ }
|
|
|
+
|
|
|
explicit constexpr vector(const array & coordinates) : raw(coordinates)
|
|
|
{
|
|
|
}
|