diff --git a/test/traits.cpp b/test/traits.cpp index 90d5e4bc..7f87b278 100644 --- a/test/traits.cpp +++ b/test/traits.cpp @@ -1,6 +1,8 @@ #include #include +#include + /////////////////////////////////////////////////////////////////////////////// template @@ -56,4 +58,10 @@ main (void) "complex function type"); tap.expect (!has_return_type::value, "integer is not applicable to func_traits"); + + + tap.expect (is_contiguous_v>, "vector is contiguous"); + tap.expect (is_contiguous_v>, "array is contiguous"); + tap.expect (!is_contiguous_v>, "list is not contiguous"); + return tap.status (); } \ No newline at end of file diff --git a/types/traits.hpp b/types/traits.hpp index fbde1c3d..14cfd55e 100644 --- a/types/traits.hpp +++ b/types/traits.hpp @@ -270,4 +270,24 @@ template using nth_argument_t = typename nth_argument::type; +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include + +template +struct is_contiguous : public std::false_type {}; + +template +struct is_contiguous> : public std::true_type {}; + +template +struct is_contiguous>: public std::true_type {}; + +template +struct is_contiguous>: public std::true_type {}; + +template +constexpr auto is_contiguous_v = is_contiguous::value; + #endif