iterator/infix: add complete make_infix overload for arrays

This commit is contained in:
Danny Robson 2020-09-30 10:57:15 +10:00
parent 19551e30ed
commit f7abb3201e

View File

@ -75,7 +75,7 @@ namespace cruft::iterator {
operator<< (std::ostream &os, const infix_t<ContainerT,CharT> &val)
{
using iterator_type = std::decay_t<
decltype(std::begin (std::declval<ContainerT> ()))
decltype(std::begin (val._container))
>;
using value_type = typename std::iterator_traits<iterator_type >::value_type;
@ -87,8 +87,7 @@ namespace cruft::iterator {
return os;
}
};
}
/// a helper function that returns an object that will use a
@ -100,18 +99,24 @@ namespace cruft::iterator {
/// std::cout << cruft::make_infix (container) << '\n';
template <typename ContainerT, typename CharT = char>
auto
make_infix (const ContainerT &_container, const CharT *_delimiter = ", ")
make_infix (ContainerT const &_container, const CharT *_delimiter = ", ")
{
return detail::infix_t<ContainerT,CharT> { _container, _delimiter };
}
template <typename ValueT, size_t CountV>
template <typename ValueT, size_t CountV, typename CharT>
auto
make_infix (const ValueT (&val)[CountV])
make_infix (const ValueT (&val)[CountV], CharT const *delimiter = ", ")
{
return make_infix (cruft::view {val});
return make_infix (cruft::view {val}, delimiter);
}
template <typename ValueT, size_t CountV, typename CharT>
auto
make_infix (ValueT (&val)[CountV], CharT const *delimiter = ", ")
{
return make_infix (cruft::view {val}, delimiter);
}
}