Skip to content

Commit ee5fc0e

Browse files
committed
Stream fixes
1 parent 6a82149 commit ee5fc0e

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ add_executable(unittesting include/stream.h
6363
include/detail/continuation_impl.h
6464
tests/stream_deduction_guides.cpp
6565
tests/filters_int_finite_stream.cpp
66-
#[[tests/filters_int_infinite_stream.cpp
66+
tests/filters_int_infinite_stream.cpp
6767
tests/filters_generic_int_stream.cpp
68-
tests/filters_move_only_finite_stream.cpp
68+
#[[tests/filters_move_only_finite_stream.cpp
6969
tests/filters_move_only_infinite_stream.cpp
7070
tests/filters_generic_move_only_stream.cpp
7171
tests/noisy.h

include/detail/continuation_impl.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ namespace stream
1717
: continuation(::std::forward<F>(continuation))
1818
{}
1919

20-
template<typename V, typename S, typename ::std::enable_if_t<ManagesFiniteness>* = nullptr>
20+
template<typename V, typename S, bool Fin = ManagesFiniteness,
21+
::std::enable_if_t<Fin>* = nullptr>
2122
decltype(auto) operator()(V &&value, const S& stream, bool &end)
2223
{
2324
return continuation(::std::forward<V>(value), stream, end);
2425
}
2526

26-
template<typename V, typename S, typename ::std::enable_if_t<!ManagesFiniteness>* = nullptr>
27+
template<typename V, typename S, bool Fin = ManagesFiniteness,
28+
::std::enable_if_t<!Fin>* = nullptr>
2729
decltype(auto) operator()(V &&value, const S& stream)
2830
{
2931
return continuation(::std::forward<V>(value), stream);

include/detail/stream_impl.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace stream
3535
{}
3636

3737
StreamImpl(Container &&container)
38-
: container(::std::move(container)), it(container.begin())
38+
: container(::std::move(container)), it(this->container.begin())
3939
{}
4040

4141
StreamImpl(::std::initializer_list<T> initList)
@@ -223,7 +223,6 @@ namespace stream
223223
public:
224224
using RealType = ValueHolder<T>;
225225

226-
227226
StreamImpl(OldStream &&oldStream, Continuation<F, ManagesFiniteness> &&continuation)
228227
: oldStream(::std::move(oldStream)), continuation(::std::move(continuation))
229228
{}
@@ -247,11 +246,24 @@ namespace stream
247246

248247
if constexpr (ManagesFiniteness)
249248
{
250-
return continuation(::std::move(oldNext).get(), static_cast<const OldStream &>(oldStream), end);
249+
auto result = continuation(::std::move(*oldNext), static_cast<const OldStream &>(oldStream), end);
250+
251+
if (!result)
252+
{
253+
return ::std::nullopt;
254+
}
255+
256+
return ::std::move(*result);
251257
}
252258
else
253259
{
254-
return continuation(::std::move(oldNext).get(), static_cast<const OldStream &>(oldStream));
260+
auto result = continuation(::std::move(*oldNext), static_cast<const OldStream &>(oldStream));
261+
if (!result)
262+
{
263+
return ::std::nullopt;
264+
}
265+
266+
return ::std::move(*result);
255267
}
256268
}
257269

include/value_holder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace stream
1111
class ValueHolder
1212
{
1313
public:
14-
static_assert(::std::is_rvalue_reference<T>::value, "RValue references isn't allowed");
14+
static_assert(!::std::is_rvalue_reference<T>::value, "RValue references isn't allowed");
1515

1616
template<typename... Args>
1717
ValueHolder(Args&&... args)

0 commit comments

Comments
 (0)