view: allow construction from anything that has begin/end
This commit is contained in:
parent
499fa4d190
commit
fb7c989487
24
view.hpp
24
view.hpp
@ -44,18 +44,28 @@ namespace cruft {
|
|||||||
m_end (last)
|
m_end (last)
|
||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
|
|
||||||
template <
|
template <
|
||||||
typename ContainerT,
|
typename ContainerT,
|
||||||
typename = std::enable_if_t<is_container_v<std::decay_t<ContainerT>>,void>
|
typename = std::void_t<
|
||||||
|
decltype (std::declval<ContainerT&> ().begin ()),
|
||||||
|
decltype (std::declval<ContainerT&> ().end ())
|
||||||
>
|
>
|
||||||
view (ContainerT &rhs):
|
>
|
||||||
view (rhs.begin (), rhs.end ())
|
view (ContainerT &rhs) noexcept (
|
||||||
|
noexcept (std::declval<ContainerT> ().begin ()) &&
|
||||||
|
noexcept (std::declval<ContainerT> ().end ())
|
||||||
|
)
|
||||||
|
: view (rhs.begin (), rhs.end ())
|
||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
|
|
||||||
template <
|
template <
|
||||||
typename ContainerT,
|
typename ContainerT,
|
||||||
typename = std::enable_if_t<is_container_v<std::decay_t<ContainerT>>,void>
|
typename = std::void_t<
|
||||||
|
decltype (std::declval<ContainerT const&> ().begin ()),
|
||||||
|
decltype (std::declval<ContainerT const&> ().end ())
|
||||||
|
>
|
||||||
>
|
>
|
||||||
view (const ContainerT &rhs):
|
view (const ContainerT &rhs):
|
||||||
view (rhs.begin (), rhs.end ())
|
view (rhs.begin (), rhs.end ())
|
||||||
@ -447,12 +457,14 @@ namespace cruft {
|
|||||||
|
|
||||||
template <typename ContainerT>
|
template <typename ContainerT>
|
||||||
view (ContainerT&) -> view<
|
view (ContainerT&) -> view<
|
||||||
typename ContainerT::iterator
|
decltype (std::declval<ContainerT&> ().begin ()),
|
||||||
|
decltype (std::declval<ContainerT&> ().end ())
|
||||||
>;
|
>;
|
||||||
|
|
||||||
template <typename ContainerT>
|
template <typename ContainerT>
|
||||||
view (const ContainerT&) -> view<
|
view (const ContainerT&) -> view<
|
||||||
typename ContainerT::const_iterator
|
decltype (std::declval<ContainerT const&> ().begin ()),
|
||||||
|
decltype (std::declval<ContainerT const&> ().end ())
|
||||||
>;
|
>;
|
||||||
|
|
||||||
// base + count constructor
|
// base + count constructor
|
||||||
|
Loading…
Reference in New Issue
Block a user