diff --git a/ostd/range.hh b/ostd/range.hh index 6d2a3d0..8a43341 100644 --- a/ostd/range.hh +++ b/ostd/range.hh @@ -2036,6 +2036,22 @@ namespace detail { }; } +/** @brief Creates a `Container` from `range`. + * + * Standard sequence containers usually support construction from an + * iterator pair. This is a utility function that will create a sequence + * container of the given type using an ostd::input_range's `iter_begin()` + * and `iter_end()` methods. + * + * The remaining arguments are passed after the two iterators. + */ +template +inline Container from_range(InputRange range, Args &&...args) { + return Container( + range.iter_begin(), range.iter_end(), std::forward(args)... + ); +} + /** @} */ } /* namespace ostd */