iterator/infix: avoid using references to temporaries in make_infix
This commit is contained in:
parent
0fe14f038d
commit
17a85e8187
@ -66,7 +66,7 @@ namespace cruft::iterator {
|
||||
namespace detail {
|
||||
template <typename ContainerT, typename CharT>
|
||||
struct infix_t {
|
||||
const ContainerT &_container;
|
||||
ContainerT _container;
|
||||
const CharT *_delimiter;
|
||||
};
|
||||
|
||||
@ -101,7 +101,18 @@ namespace cruft::iterator {
|
||||
auto
|
||||
make_infix (ContainerT const &_container, const CharT *_delimiter = ", ")
|
||||
{
|
||||
return detail::infix_t<ContainerT,CharT> { _container, _delimiter };
|
||||
return detail::infix_t<ContainerT const&,CharT> { _container, _delimiter };
|
||||
}
|
||||
|
||||
|
||||
template <typename ContainerT, typename CharT = char>
|
||||
auto
|
||||
make_infix (ContainerT &&_container, const CharT *_delimiter = ", ")
|
||||
{
|
||||
return detail::infix_t<std::remove_reference_t<ContainerT>,CharT> {
|
||||
std::forward<ContainerT> (_container),
|
||||
_delimiter
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user