- Extracted traits from class to a detail namespace.

master
faluco 4 years ago committed by Francisco Paisana
parent 072e84cec8
commit 1253740da3

@ -31,37 +31,38 @@
namespace srslte {
/// The class template span describes an object that can refer to a contiguous sequence of objects with the first
/// element of the sequence at position zero.
template <typename T>
class span
{
/// Helper traits used by SFINAE expressions in constructors.
class span;
namespace detail {
template <typename... Ts>
struct make_void {
/// Helper traits used by SFINAE expressions in constructors.
template <typename... Ts>
struct make_void {
typedef void type;
};
template <typename... Ts>
using void_t = typename make_void<Ts...>::type;
template <typename U>
struct is_span : std::false_type {};
template <typename U>
struct is_span<span<U> > : std::true_type {};
template <typename U>
struct is_std_array : std::false_type {};
template <typename U, std::size_t N>
struct is_std_array<std::array<U, N> > : std::true_type {};
template <typename U>
using remove_cvref_t = typename std::remove_cv<typename std::remove_reference<U>::type>::type;
template <class Container, class U, class = void>
struct is_container_compatible : public std::false_type {};
template <class Container, class U>
struct is_container_compatible<
};
template <typename... Ts>
using void_t = typename make_void<Ts...>::type;
template <typename U>
struct is_span : std::false_type {};
template <typename U>
struct is_span<span<U> > : std::true_type {};
template <typename U>
struct is_std_array : std::false_type {};
template <typename U, std::size_t N>
struct is_std_array<std::array<U, N> > : std::true_type {};
template <typename U>
using remove_cvref_t = typename std::remove_cv<typename std::remove_reference<U>::type>::type;
template <class Container, class U, class = void>
struct is_container_compatible : public std::false_type {};
template <class Container, class U>
struct is_container_compatible<
Container,
U,
void_t<
@ -80,6 +81,13 @@ class span
U (*)[]>::value,
int>::type> > : public std::true_type {};
} // namespace detail
/// The class template span describes an object that can refer to a contiguous sequence of objects with the first
/// element of the sequence at position zero.
template <typename T>
class span
{
public:
/// Member types.
using element_type = T;
@ -123,13 +131,14 @@ public:
/// Constructs a span that is a view over the container c.
template <typename Container,
typename std::enable_if<is_container_compatible<Container, element_type>::value, int>::type = 0>
typename std::enable_if<detail::is_container_compatible<Container, element_type>::value, int>::type = 0>
constexpr span(Container& c) noexcept : ptr(c.data()), len(c.size())
{}
/// Constructs a span that is a view over the container c.
template <typename Container,
typename std::enable_if<is_container_compatible<const Container, element_type>::value, int>::type = 0>
template <
typename Container,
typename std::enable_if<detail::is_container_compatible<const Container, element_type>::value, int>::type = 0>
constexpr span(const Container& c) noexcept : ptr(c.data()), len(c.size())
{}

Loading…
Cancel
Save