Be more permissive with vector & point constructor argument types & array index types

This commit is contained in:
Nikita Lisitsa 2020-09-13 12:49:34 +03:00
parent e3f9770dea
commit 0453d4e15d
3 changed files with 4 additions and 4 deletions

View file

@ -24,7 +24,7 @@ namespace psemek::geom
template <typename ... Args> template <typename ... Args>
point(Args && ... args) point(Args && ... args)
: coords{ std::forward<Args>(args)... } : coords{ static_cast<T>(std::forward<Args>(args))... }
{ {
static_assert(sizeof...(Args) == N); static_assert(sizeof...(Args) == N);
} }

View file

@ -27,7 +27,7 @@ namespace psemek::geom
template <typename ... Args> template <typename ... Args>
vector(Args && ... args) vector(Args && ... args)
: coords{ std::forward<Args>(args)... } : coords{ static_cast<T>(std::forward<Args>(args))... }
{ {
static_assert(sizeof...(Args) == N); static_assert(sizeof...(Args) == N);
} }

View file

@ -215,7 +215,7 @@ namespace psemek::util
template <typename ... Ixs> template <typename ... Ixs>
T & array<T, N>::operator()(Ixs ... ixs) T & array<T, N>::operator()(Ixs ... ixs)
{ {
dims_type dims{ixs...}; dims_type dims{static_cast<std::size_t>(ixs)...};
return (*this)(dims); return (*this)(dims);
} }
@ -223,7 +223,7 @@ namespace psemek::util
template <typename ... Ixs> template <typename ... Ixs>
T const & array<T, N>::operator()(Ixs ... ixs) const T const & array<T, N>::operator()(Ixs ... ixs) const
{ {
dims_type dims{ixs...}; dims_type dims{static_cast<std::size_t>(ixs)...};
return (*this)(dims); return (*this)(dims);
} }