types/description: use the inner_type for descriptions
This commit is contained in:
parent
3ff6873e4c
commit
ef560d8c1e
@ -258,26 +258,4 @@ namespace cruft::types {
|
||||
::cruft::is_coord_v<CoordT>
|
||||
>
|
||||
> : public ::cruft::arity<CoordT> { };
|
||||
|
||||
|
||||
template <typename CoordT>
|
||||
struct category_traits<
|
||||
CoordT,
|
||||
std::enable_if_t<
|
||||
::cruft::is_coord_v<CoordT>
|
||||
>
|
||||
> : public category_traits<
|
||||
::cruft::value_trait_t<CoordT>
|
||||
> { };
|
||||
|
||||
|
||||
template <typename CoordT>
|
||||
struct signedness_traits<
|
||||
CoordT,
|
||||
std::enable_if_t<
|
||||
::cruft::is_coord_v<CoordT>
|
||||
>
|
||||
> : public signedness_traits<
|
||||
::cruft::value_trait_t<CoordT>
|
||||
> { };
|
||||
}
|
||||
|
@ -143,18 +143,4 @@ namespace cruft::types {
|
||||
::cruft::strongdef::index<TagT, ValueT>
|
||||
> : public arity_trait<ValueT>
|
||||
{ ; };
|
||||
|
||||
|
||||
template <typename TagT, typename ValueT>
|
||||
struct category_traits<
|
||||
::cruft::strongdef::index<TagT,ValueT>
|
||||
> : public std::integral_constant<category,category::ENUM>
|
||||
{ ; };
|
||||
|
||||
|
||||
template <typename TagT, typename ValueT>
|
||||
struct signedness_traits<
|
||||
::cruft::strongdef::index<TagT,ValueT>
|
||||
> : public signedness_traits<ValueT>
|
||||
{ ; };
|
||||
};
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "types/description.hpp"
|
||||
#include "types/dispatch.hpp"
|
||||
#include "types.hpp"
|
||||
#include "vector.hpp"
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -75,5 +76,23 @@ int main ()
|
||||
"enum type descriptor dispatches correctly"
|
||||
);
|
||||
|
||||
{
|
||||
auto const vector_descriptor = cruft::types::make_description<cruft::vector2f> ();
|
||||
|
||||
tap.expect_eq (
|
||||
vector_descriptor.category,
|
||||
cruft::types::category_traits_v<float>,
|
||||
"vector2f type is float category"
|
||||
);
|
||||
|
||||
tap.expect_eq (vector_descriptor.signedness, true, "vector2f type is signed");
|
||||
tap.expect_eq (vector_descriptor.width, sizeof (float), "vector2f width is sizeof(float)");
|
||||
tap.expect_eq (vector_descriptor.arity, 2u, "vector2f arity is 2");
|
||||
tap.expect_eq (vector_descriptor.alignment, alignof (cruft::vector2f), "vector2f alignment matches");
|
||||
tap.expect_eq (vector_descriptor.index, cruft::typeidx<cruft::vector2f> (), "vector2f index matches");
|
||||
tap.expect_eq (vector_descriptor.bytes (), sizeof (cruft::vector2f), "vector2f bytes matches");
|
||||
|
||||
}
|
||||
|
||||
return tap.status ();
|
||||
}
|
@ -8,6 +8,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "traits.hpp"
|
||||
|
||||
#include "../std.hpp"
|
||||
#include "../debug/panic.hpp"
|
||||
#include "../typeidx.hpp"
|
||||
@ -258,10 +260,12 @@ namespace cruft::types {
|
||||
.index = cruft::typeidx<T> (),
|
||||
};
|
||||
} else {
|
||||
using inner_t = cruft::inner_type_t<T>;
|
||||
|
||||
return {
|
||||
.category = category_traits_v<T>,
|
||||
.signedness = signedness_traits_v<T>,
|
||||
.width = sizeof (T),
|
||||
.category = category_traits_v<inner_t>,
|
||||
.signedness = signedness_traits_v<inner_t>,
|
||||
.width = sizeof (inner_t),
|
||||
.arity = arity_v<T>,
|
||||
.alignment = alignof (T),
|
||||
.index = cruft::typeidx<T> (),
|
||||
|
Loading…
Reference in New Issue
Block a user