Skip to content

Commit 2ef2c8a

Browse files
committed
private value ctor
1 parent 048db19 commit 2ef2c8a

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

sliding_window.hpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,40 @@
1212
#include <iterator>
1313

1414
namespace iter {
15+
template <typename Container>
16+
class SlidingWindow;
17+
18+
template <typename Container>
19+
SlidingWindow<Container> sliding_window(Container&&, std::size_t);
20+
21+
template <typename T>
22+
SlidingWindow<std::initializer_list<T>> sliding_window(
23+
std::initializer_list<T>, std::size_t);
24+
1525
template <typename Container>
1626
class SlidingWindow {
1727
private:
1828
Container container;
1929
std::size_t window_size;
2030

21-
public:
31+
friend SlidingWindow sliding_window<Container>(
32+
Container&&, std::size_t);
33+
34+
template <typename T>
35+
friend SlidingWindow<std::initializer_list<T>> sliding_window(
36+
std::initializer_list<T>, std::size_t);
37+
2238
SlidingWindow(Container container, std::size_t win_sz)
2339
: container(std::forward<Container>(container)),
2440
window_size{win_sz}
2541
{ }
2642

43+
public:
44+
2745
class Iterator {
2846
private:
29-
// confusing, but, just makes the type of the vector returned by
30-
// operator*()
47+
// confusing, but, just makes the type of the vector
48+
// returned by operator*()
3149
using OpDerefElemType =
3250
std::reference_wrapper<
3351
typename std::remove_reference<

0 commit comments

Comments
 (0)