Skip to content

Commit

Permalink
Replace boost::optional by std::optional
Browse files Browse the repository at this point in the history
  • Loading branch information
arximboldi committed Jul 31, 2017
1 parent 688c771 commit 3bd4260
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/ewig/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static const auto global_commands = commands
{"page-down", scroll_command(page_down)},
{"page-up", scroll_command(page_up)},
{"paste", paste_command(insert_text)},
{"quit", [](auto, auto) { return boost::none; }},
{"quit", [](auto, auto) { return std::nullopt; }},
{"save", save},
{"undo", edit_command(undo)},
{"start-selection", edit_command(start_selection)},
Expand Down Expand Up @@ -93,7 +93,7 @@ application clear_input(application state)
return state;
}

boost::optional<application> update(application state, event ev)
std::optional<application> update(application state, event ev)
{
state.input = state.input.push_back(ev.key);
const auto& map = state.keys.get();
Expand All @@ -116,7 +116,7 @@ boost::optional<application> update(application state, event ev)
return state;
}

boost::optional<application>
std::optional<application>
eval_command(application state, const std::string& cmd, coord size)
{
auto it = global_commands.find(cmd);
Expand Down
6 changes: 3 additions & 3 deletions src/ewig/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ struct event
coord size;
};

using command = std::function<boost::optional<application>(application, coord)>;
using command = std::function<std::optional<application>(application, coord)>;

application save(application app, coord);
application paste(application app, coord size);
application put_message(application state, std::string str);
application put_clipboard(application state, text content);

boost::optional<application> eval_command(application state, const std::string& cmd, coord editor_size);
std::optional<application> eval_command(application state, const std::string& cmd, coord editor_size);

application clear_input(application state);
boost::optional<application> update(application state, event ev);
std::optional<application> update(application state, event ev);

application apply_edit(application state, coord size, buffer edit);
application apply_edit(application state, coord size, std::pair<buffer, text> edit);
Expand Down
9 changes: 4 additions & 5 deletions src/ewig/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include <immer/flex_vector_transient.hpp>
#include <immer/algorithm.hpp>
#include <boost/optional.hpp>

#include <algorithm>
#include <fstream>
Expand Down Expand Up @@ -370,14 +369,14 @@ std::pair<buffer, text> cut(buffer buf)
buf.cursor = starts;
}

buf.selection_start = boost::none;
buf.selection_start = std::nullopt;
return {buf, selection};
}

std::pair<buffer, text> copy(buffer buf)
{
auto result = selected_text(buf);
buf.selection_start = boost::none;
buf.selection_start = std::nullopt;
return {buf, result};
}

Expand All @@ -397,7 +396,7 @@ buffer select_whole_buffer(buffer buf)

buffer clear_selection(buffer buf)
{
buf.selection_start = boost::none;
buf.selection_start = std::nullopt;
return buf;
}

Expand Down Expand Up @@ -434,7 +433,7 @@ buffer record(buffer before, buffer after)
if (before.content != after.content) {
after.history = after.history.push_back({before.content, before.cursor});
if (before.history_pos == after.history_pos)
after.history_pos = boost::none;
after.history_pos = std::nullopt;
}
return after;
}
Expand Down
6 changes: 3 additions & 3 deletions src/ewig/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <immer/flex_vector.hpp>
#include <immer/vector.hpp>

#include <boost/optional.hpp>
#include <optional>

namespace ewig {

Expand All @@ -51,9 +51,9 @@ struct buffer
text content;
coord cursor;
coord scroll;
boost::optional<coord> selection_start;
std::optional<coord> selection_start;
immer::vector<snapshot> history;
boost::optional<std::size_t> history_pos;
std::optional<std::size_t> history_pos;
};

constexpr auto tab_width = 8;
Expand Down
4 changes: 2 additions & 2 deletions src/ewig/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

#include <boost/fusion/adapted/std_tuple.hpp>
#include <boost/functional/hash.hpp>
#include <boost/optional.hpp>

#include <optional>
#include <tuple>

namespace std
Expand Down Expand Up @@ -54,7 +54,7 @@ struct hash<immer::vector<T>>
namespace ewig {

template <typename T, typename Fn>
boost::optional<T> optional_map(boost::optional<T> v, Fn&& fn)
std::optional<T> optional_map(std::optional<T> v, Fn&& fn)
{
return v ? std::forward<Fn>(fn)(std::move(*v)) : v;
}
Expand Down

0 comments on commit 3bd4260

Please sign in to comment.