2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Move to std::optional.

This commit is contained in:
John Preston
2018-09-21 19:28:46 +03:00
parent 850efbde95
commit 2e5a0e056c
115 changed files with 632 additions and 672 deletions

View File

@@ -21,17 +21,17 @@ namespace details {
template <typename ...Values>
struct combine_state {
combine_state() : accumulated(std::tuple<base::optional<Values>...>()) {
combine_state() : accumulated(std::tuple<std::optional<Values>...>()) {
}
base::optional<std::tuple<base::optional<Values>...>> accumulated;
base::optional<std::tuple<Values...>> latest;
std::optional<std::tuple<std::optional<Values>...>> accumulated;
std::optional<std::tuple<Values...>> latest;
int invalid = sizeof...(Values);
int working = sizeof...(Values);
};
template <typename ...Values, std::size_t ...I>
inline std::tuple<Values...> combine_make_first(
std::tuple<base::optional<Values>...> &&accumulated,
std::tuple<std::optional<Values>...> &&accumulated,
std::index_sequence<I...>) {
return std::make_tuple(std::move(*std::get<I>(accumulated))...);
}
@@ -65,7 +65,7 @@ public:
state->latest = combine_make_first(
std::move(*state->accumulated),
std::make_index_sequence<kArity>());
state->accumulated = base::none;
state->accumulated = std::nullopt;
consumer.put_next_copy(*state->latest);
}
}
@@ -276,7 +276,7 @@ namespace details {
template <typename Value>
struct combine_vector_state {
std::vector<base::optional<Value>> accumulated;
std::vector<std::optional<Value>> accumulated;
std::vector<Value> latest;
int invalid = 0;
int working = 0;

View File

@@ -22,7 +22,7 @@ public:
initial = std::move(initial)
](const auto &consumer) mutable {
auto previous = consumer.template make_state<
base::optional<Value>
std::optional<Value>
>();
return std::move(initial).start(
[consumer, previous](auto &&value) {

View File

@@ -22,7 +22,7 @@ public:
initial = std::move(initial)
](const auto &consumer) mutable {
auto previous = consumer.template make_state<
base::optional<Value>
std::optional<Value>
>();
return std::move(initial).start(
[consumer, previous](auto &&value) {

View File

@@ -95,13 +95,13 @@ private:
template <typename Value>
inline const Value &deref_optional_helper(
const base::optional<Value> &value) {
const std::optional<Value> &value) {
return *value;
}
template <typename Value>
inline Value &&deref_optional_helper(
base::optional<Value> &&value) {
std::optional<Value> &&value) {
return std::move(*value);
}
@@ -109,7 +109,7 @@ class filter_optional_helper {
public:
template <typename Value, typename Error, typename Generator>
auto operator()(producer<
base::optional<Value>,
std::optional<Value>,
Error,
Generator> &&initial) const {
return make_producer<Value, Error>([