rename vector value_type to component_type

This commit is contained in:
BlackMATov
2020-12-03 06:30:56 +07:00
parent dc05e543a4
commit 6513122fc5
4 changed files with 17 additions and 17 deletions

View File

@@ -122,13 +122,13 @@ public:
template < typename T, size_t Size > template < typename T, size_t Size >
class vec final : public vec_base<T, Size> { class vec final : public vec_base<T, Size> {
public: public:
using value_type = T; using component_type = T;
using pointer = value_type*; using pointer = component_type*;
using const_pointer = const value_type*; using const_pointer = const component_type*;
using reference = value_type&; using reference = component_type&;
using const_reference = const value_type&; using const_reference = const component_type&;
static constexpr size_t size = Size; static constexpr size_t size = Size;

View File

@@ -21,7 +21,7 @@ namespace vmath_hpp::detail
template < typename A, std::size_t Size, typename F, std::size_t... Is > template < typename A, std::size_t Size, typename F, std::size_t... Is >
[[nodiscard]] constexpr VMATH_HPP_FORCE_INLINE [[nodiscard]] constexpr VMATH_HPP_FORCE_INLINE
auto map_impl(F&& f, const mat<A, Size>& a, std::index_sequence<Is...>) auto map_impl(F&& f, const mat<A, Size>& a, std::index_sequence<Is...>)
-> mat<typename std::invoke_result_t<F, vec<A, Size>>::value_type, Size> -> mat<typename std::invoke_result_t<F, vec<A, Size>>::component_type, Size>
{ {
return { f(a[Is])... }; return { f(a[Is])... };
} }
@@ -29,7 +29,7 @@ namespace vmath_hpp::detail
template < typename A, typename B, std::size_t Size, typename F, std::size_t... Is > template < typename A, typename B, std::size_t Size, typename F, std::size_t... Is >
[[nodiscard]] constexpr VMATH_HPP_FORCE_INLINE [[nodiscard]] constexpr VMATH_HPP_FORCE_INLINE
auto zip_impl(F&& f, const mat<A, Size>& a, const mat<B, Size>& b, std::index_sequence<Is...>) auto zip_impl(F&& f, const mat<A, Size>& a, const mat<B, Size>& b, std::index_sequence<Is...>)
-> mat<typename std::invoke_result_t<F, vec<A, Size>, vec<B, Size>>::value_type, Size> -> mat<typename std::invoke_result_t<F, vec<A, Size>, vec<B, Size>>::component_type, Size>
{ {
return { f(a[Is], b[Is])... }; return { f(a[Is], b[Is])... };
} }
@@ -37,7 +37,7 @@ namespace vmath_hpp::detail
template < typename A, typename B, typename C, std::size_t Size, typename F, std::size_t... Is > template < typename A, typename B, typename C, std::size_t Size, typename F, std::size_t... Is >
[[nodiscard]] constexpr VMATH_HPP_FORCE_INLINE [[nodiscard]] constexpr VMATH_HPP_FORCE_INLINE
auto zip_impl(F&& f, const mat<A, Size>& a, const mat<B, Size>& b, const mat<C, Size>& c, std::index_sequence<Is...>) auto zip_impl(F&& f, const mat<A, Size>& a, const mat<B, Size>& b, const mat<C, Size>& c, std::index_sequence<Is...>)
-> mat<typename std::invoke_result_t<F, vec<A, Size>, vec<B, Size>, vec<C, Size>>::value_type, Size> -> mat<typename std::invoke_result_t<F, vec<A, Size>, vec<B, Size>, vec<C, Size>>::component_type, Size>
{ {
return { f(a[Is], b[Is], c[Is])... }; return { f(a[Is], b[Is], c[Is])... };
} }
@@ -65,7 +65,7 @@ namespace vmath_hpp::detail
template < typename A, std::size_t Size, typename F > template < typename A, std::size_t Size, typename F >
[[nodiscard]] constexpr VMATH_HPP_FORCE_INLINE [[nodiscard]] constexpr VMATH_HPP_FORCE_INLINE
auto map(F&& f, const mat<A, Size>& a) auto map(F&& f, const mat<A, Size>& a)
-> mat<typename std::invoke_result_t<F, vec<A, Size>>::value_type, Size> -> mat<typename std::invoke_result_t<F, vec<A, Size>>::component_type, Size>
{ {
return impl::map_impl(std::forward<F>(f), a, std::make_index_sequence<Size>{}); return impl::map_impl(std::forward<F>(f), a, std::make_index_sequence<Size>{});
} }
@@ -73,7 +73,7 @@ namespace vmath_hpp::detail
template < typename A, typename B, std::size_t Size, typename F > template < typename A, typename B, std::size_t Size, typename F >
[[nodiscard]] constexpr VMATH_HPP_FORCE_INLINE [[nodiscard]] constexpr VMATH_HPP_FORCE_INLINE
auto zip(F&& f, const mat<A, Size>& a, const mat<B, Size>& b) auto zip(F&& f, const mat<A, Size>& a, const mat<B, Size>& b)
-> mat<typename std::invoke_result_t<F, vec<A, Size>, vec<B, Size>>::value_type, Size> -> mat<typename std::invoke_result_t<F, vec<A, Size>, vec<B, Size>>::component_type, Size>
{ {
return impl::zip_impl(std::forward<F>(f), a, b, std::make_index_sequence<Size>{}); return impl::zip_impl(std::forward<F>(f), a, b, std::make_index_sequence<Size>{});
} }
@@ -81,7 +81,7 @@ namespace vmath_hpp::detail
template < typename A, typename B, typename C, std::size_t Size, typename F > template < typename A, typename B, typename C, std::size_t Size, typename F >
[[nodiscard]] constexpr VMATH_HPP_FORCE_INLINE [[nodiscard]] constexpr VMATH_HPP_FORCE_INLINE
auto zip(F&& f, const mat<A, Size>& a, const mat<B, Size>& b, const mat<C, Size>& c) auto zip(F&& f, const mat<A, Size>& a, const mat<B, Size>& b, const mat<C, Size>& c)
-> mat<typename std::invoke_result_t<F, vec<A, Size>, vec<B, Size>, vec<C, Size>>::value_type, Size> -> mat<typename std::invoke_result_t<F, vec<A, Size>, vec<B, Size>, vec<C, Size>>::component_type, Size>
{ {
return impl::zip_impl(std::forward<F>(f), a, b, c, std::make_index_sequence<Size>{}); return impl::zip_impl(std::forward<F>(f), a, b, c, std::make_index_sequence<Size>{});
} }

View File

@@ -151,13 +151,13 @@ namespace vmath_hpp
using self_type = vec; using self_type = vec;
using base_type = detail::vec_base<T, Size>; using base_type = detail::vec_base<T, Size>;
public: public:
using value_type = T; using component_type = T;
using pointer = value_type*; using pointer = component_type*;
using const_pointer = const value_type*; using const_pointer = const component_type*;
using reference = value_type&; using reference = component_type&;
using const_reference = const value_type&; using const_reference = const component_type&;
static constexpr std::size_t size = Size; static constexpr std::size_t size = Size;
public: public:

View File

@@ -101,7 +101,7 @@ TEST_CASE("vmath/ext") {
{ {
constexpr auto v = cast_to<int>(float2{1.5f}); constexpr auto v = cast_to<int>(float2{1.5f});
STATIC_REQUIRE(v == int2(1)); STATIC_REQUIRE(v == int2(1));
STATIC_REQUIRE(std::is_same_v<decltype(v)::value_type, int>); STATIC_REQUIRE(std::is_same_v<decltype(v)::component_type, int>);
} }
{ {
constexpr auto m = cast_to<int>(float2x2{1.5f}); constexpr auto m = cast_to<int>(float2x2{1.5f});