Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Move to C++17 #1602

Merged
merged 8 commits into from
Dec 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if(COMMAND cmake_policy)
cmake_policy(SET CMP0023 NEW)
endif(COMMAND cmake_policy)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down
2 changes: 1 addition & 1 deletion src/badguy/mriceblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ MrIceBlock::collision_squished(GameObject& object)
break;
}
}
BOOST_FALLTHROUGH;
[[fallthrough]];

case ICESTATE_NORMAL:
{
Expand Down
4 changes: 2 additions & 2 deletions src/badguy/snail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Snail::collision_solid(const CollisionHit& hit)
m_physic.set_velocity_x(-m_physic.get_velocity_x());
}
}
BOOST_FALLTHROUGH;
[[fallthrough]];
case STATE_FLAT:
case STATE_KICKED_DELAY:
if (hit.top || hit.bottom) {
Expand Down Expand Up @@ -298,7 +298,7 @@ Snail::collision_squished(GameObject& object)
player->bounce(*this);
break;
}
BOOST_FALLTHROUGH;
[[fallthrough]];
case STATE_KICKED:
squishcount++;
if (squishcount >= MAX_SNAIL_SQUISHES) {
Expand Down
4 changes: 2 additions & 2 deletions src/control/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ std::string Control_to_string(Control control)
return g_control_names[static_cast<int>(control)];
}

boost::optional<Control> Control_from_string(const std::string& text)
std::optional<Control> Control_from_string(const std::string& text)
{
for(int i = 0; g_control_names[i] != nullptr; ++i) {
if (text == g_control_names[i]) {
return static_cast<Control>(i);
}
}

return boost::none;
return std::nullopt;
}

Controller::Controller()
Expand Down
6 changes: 4 additions & 2 deletions src/control/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#define HEADER_SUPERTUX_CONTROL_CONTROLLER_HPP

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

enum class Control {
LEFT = 0,
Expand Down Expand Up @@ -51,7 +53,7 @@ enum class Control {
std::ostream& operator<<(std::ostream& os, Control control);

std::string Control_to_string(Control control);
boost::optional<Control> Control_from_string(const std::string& text);
std::optional<Control> Control_from_string(const std::string& text);

class Controller
{
Expand Down
2 changes: 1 addition & 1 deletion src/control/joystick_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ JoystickConfig::read(const ReaderMapping& joystick_mapping)
std::string control_text;
map.get("control", control_text);

const boost::optional<Control> maybe_control = Control_from_string(control_text);
const std::optional<Control> maybe_control = Control_from_string(control_text);
if (!maybe_control)
{
log_info << "Invalid control '" << control_text << "' in buttonmap" << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions src/control/keyboard_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "control/keyboard_config.hpp"

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

#include "util/log.hpp"
#include "util/reader_mapping.hpp"
Expand Down Expand Up @@ -92,7 +92,7 @@ KeyboardConfig::read(const ReaderMapping& keymap_mapping)
std::string control_text;
map.get("control", control_text);

const boost::optional<Control> maybe_control = Control_from_string(control_text);
const std::optional<Control> maybe_control = Control_from_string(control_text);
if (maybe_control) {
if (m_configurable_controls.count(*maybe_control)) {
bind_key(static_cast<SDL_Keycode>(key), *maybe_control);
Expand Down
2 changes: 1 addition & 1 deletion src/control/keyboard_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ KeyboardManager::process_menu_key_event(const SDL_KeyboardEvent& event)
}
m_parent->reset();
MenuManager::instance().refresh();
m_wait_for_key = boost::none;
m_wait_for_key = std::nullopt;
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/control/keyboard_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#ifndef HEADER_SUPERTUX_CONTROL_KEYBOARD_MANAGER_HPP
#define HEADER_SUPERTUX_CONTROL_KEYBOARD_MANAGER_HPP

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

#include "control/controller.hpp"

Expand All @@ -42,7 +42,7 @@ class KeyboardManager final
private:
InputManager* m_parent;
KeyboardConfig& m_keyboard_config;
boost::optional<Control> m_wait_for_key;
std::optional<Control> m_wait_for_key;
bool m_lock_text_input;

private:
Expand Down
4 changes: 2 additions & 2 deletions src/editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ Editor::get_level_directory() const
}

void
Editor::test_level(const boost::optional<std::pair<std::string, Vector>>& test_pos)
Editor::test_level(const std::optional<std::pair<std::string, Vector>>& test_pos)
{

Tile::draw_editor_images = false;
Expand Down Expand Up @@ -648,7 +648,7 @@ Editor::event(const SDL_Event& ev)
if (ev.type == SDL_KEYDOWN &&
ev.key.keysym.sym == SDLK_t &&
ev.key.keysym.mod & KMOD_CTRL) {
test_level(boost::none);
test_level(std::nullopt);
}

if (ev.type == SDL_KEYDOWN &&
Expand Down
4 changes: 2 additions & 2 deletions src/editor/editor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class Editor final : public Screen,
void reload_level();
void quit_editor();
void save_level();
void test_level(const boost::optional<std::pair<std::string, Vector>>& test_pos);
void test_level(const std::optional<std::pair<std::string, Vector>>& test_pos);
void update_keyboard(const Controller& controller);

protected:
Expand All @@ -172,7 +172,7 @@ class Editor final : public Screen,
bool m_save_request;
bool m_test_request;
bool m_particle_editor_request;
boost::optional<std::pair<std::string, Vector>> m_test_pos;
std::optional<std::pair<std::string, Vector>> m_test_pos;

std::unique_ptr<Savegame> m_savegame;
std::string* m_particle_editor_filename;
Expand Down
16 changes: 8 additions & 8 deletions src/editor/object_option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ObjectOption::~ObjectOption()
}

BoolObjectOption::BoolObjectOption(const std::string& text, bool* pointer, const std::string& key,
boost::optional<bool> default_value,
std::optional<bool> default_value,
unsigned int flags) :
ObjectOption(text, key, flags),
m_pointer(pointer),
Expand Down Expand Up @@ -84,7 +84,7 @@ BoolObjectOption::to_string() const
}

IntObjectOption::IntObjectOption(const std::string& text, int* pointer, const std::string& key,
boost::optional<int> default_value,
std::optional<int> default_value,
unsigned int flags) :
ObjectOption(text, key, flags),
m_pointer(pointer),
Expand Down Expand Up @@ -150,7 +150,7 @@ RectfObjectOption::add_to_menu(Menu& menu) const
}

FloatObjectOption::FloatObjectOption(const std::string& text, float* pointer, const std::string& key,
boost::optional<float> default_value,
std::optional<float> default_value,
unsigned int flags) :
ObjectOption(text, key, flags),
m_pointer(pointer),
Expand Down Expand Up @@ -183,7 +183,7 @@ FloatObjectOption::add_to_menu(Menu& menu) const
}

StringObjectOption::StringObjectOption(const std::string& text, std::string* pointer, const std::string& key,
boost::optional<std::string> default_value,
std::optional<std::string> default_value,
unsigned int flags) :
ObjectOption(text, key, flags),
m_pointer(pointer),
Expand Down Expand Up @@ -217,7 +217,7 @@ StringObjectOption::add_to_menu(Menu& menu) const

StringSelectObjectOption::StringSelectObjectOption(const std::string& text, int* pointer,
const std::vector<std::string>& select,
boost::optional<int> default_value,
std::optional<int> default_value,
const std::string& key, unsigned int flags) :
ObjectOption(text, key, flags),
m_pointer(pointer),
Expand Down Expand Up @@ -262,7 +262,7 @@ StringSelectObjectOption::add_to_menu(Menu& menu) const
EnumObjectOption::EnumObjectOption(const std::string& text, int* pointer,
const std::vector<std::string>& labels,
const std::vector<std::string>& symbols,
boost::optional<int> default_value,
std::optional<int> default_value,
const std::string& key, unsigned int flags) :
ObjectOption(text, key, flags),
m_pointer(pointer),
Expand Down Expand Up @@ -341,7 +341,7 @@ ScriptObjectOption::add_to_menu(Menu& menu) const
}

FileObjectOption::FileObjectOption(const std::string& text, std::string* pointer,
boost::optional<std::string> default_value,
std::optional<std::string> default_value,
const std::string& key,
std::vector<std::string> filter,
const std::string& basedir,
Expand Down Expand Up @@ -383,7 +383,7 @@ FileObjectOption::add_to_menu(Menu& menu) const
}

ColorObjectOption::ColorObjectOption(const std::string& text, Color* pointer, const std::string& key,
boost::optional<Color> default_value, bool use_alpha,
std::optional<Color> default_value, bool use_alpha,
unsigned int flags) :
ObjectOption(text, key, flags),
m_pointer(pointer),
Expand Down
35 changes: 18 additions & 17 deletions src/editor/object_option.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#ifndef HEADER_SUPERTUX_EDITOR_OBJECT_OPTION_HPP
#define HEADER_SUPERTUX_EDITOR_OBJECT_OPTION_HPP

#include <boost/optional.hpp>
#include <optional>
#include <functional>
#include <string>
#include <vector>

Expand Down Expand Up @@ -73,7 +74,7 @@ class BoolObjectOption : public ObjectOption
{
public:
BoolObjectOption(const std::string& text, bool* pointer, const std::string& key,
boost::optional<bool> default_value,
std::optional<bool> default_value,
unsigned int flags);

virtual void save(Writer& write) const override;
Expand All @@ -82,7 +83,7 @@ class BoolObjectOption : public ObjectOption

private:
bool* const m_pointer;
const boost::optional<bool> m_default_value;
const std::optional<bool> m_default_value;

private:
BoolObjectOption(const BoolObjectOption&) = delete;
Expand All @@ -93,7 +94,7 @@ class IntObjectOption : public ObjectOption
{
public:
IntObjectOption(const std::string& text, int* pointer, const std::string& key,
boost::optional<int> default_value,
std::optional<int> default_value,
unsigned int flags);

virtual void save(Writer& write) const override;
Expand All @@ -102,7 +103,7 @@ class IntObjectOption : public ObjectOption

private:
int* const m_pointer;
const boost::optional<int> m_default_value;
const std::optional<int> m_default_value;

private:
IntObjectOption(const IntObjectOption&) = delete;
Expand Down Expand Up @@ -133,7 +134,7 @@ class FloatObjectOption : public ObjectOption
{
public:
FloatObjectOption(const std::string& text, float* pointer, const std::string& key,
boost::optional<float> default_value,
std::optional<float> default_value,
unsigned int flags);

virtual void save(Writer& write) const override;
Expand All @@ -142,7 +143,7 @@ class FloatObjectOption : public ObjectOption

private:
float* const m_pointer;
const boost::optional<float> m_default_value;
const std::optional<float> m_default_value;

private:
FloatObjectOption(const FloatObjectOption&) = delete;
Expand All @@ -153,7 +154,7 @@ class StringObjectOption : public ObjectOption
{
public:
StringObjectOption(const std::string& text, std::string* pointer, const std::string& key,
boost::optional<std::string> default_value,
std::optional<std::string> default_value,
unsigned int flags);

virtual void save(Writer& write) const override;
Expand All @@ -162,7 +163,7 @@ class StringObjectOption : public ObjectOption

private:
std::string* const m_pointer;
boost::optional<std::string> m_default_value;
std::optional<std::string> m_default_value;

private:
StringObjectOption(const StringObjectOption&) = delete;
Expand All @@ -173,7 +174,7 @@ class StringSelectObjectOption : public ObjectOption
{
public:
StringSelectObjectOption(const std::string& text, int* pointer, const std::vector<std::string>& select,
boost::optional<int> default_value,
std::optional<int> default_value,
const std::string& key, unsigned int flags);

virtual void save(Writer& write) const override;
Expand All @@ -183,7 +184,7 @@ class StringSelectObjectOption : public ObjectOption
private:
int* const m_pointer;
const std::vector<std::string> m_select;
const boost::optional<int> m_default_value;
const std::optional<int> m_default_value;

private:
StringSelectObjectOption(const StringSelectObjectOption&) = delete;
Expand All @@ -196,7 +197,7 @@ class EnumObjectOption : public ObjectOption
EnumObjectOption(const std::string& text, int* pointer,
const std::vector<std::string>& labels,
const std::vector<std::string>& symbols,
boost::optional<int> default_value,
std::optional<int> default_value,
const std::string& key, unsigned int flags);

virtual void save(Writer& write) const override;
Expand All @@ -207,7 +208,7 @@ class EnumObjectOption : public ObjectOption
int* const m_pointer;
const std::vector<std::string> m_labels;
const std::vector<std::string> m_symbols;
const boost::optional<int> m_default_value;
const std::optional<int> m_default_value;

private:
EnumObjectOption(const EnumObjectOption&) = delete;
Expand Down Expand Up @@ -236,7 +237,7 @@ class FileObjectOption : public ObjectOption
{
public:
FileObjectOption(const std::string& text, std::string* pointer,
boost::optional<std::string> default_value,
std::optional<std::string> default_value,
const std::string& key,
std::vector<std::string> filter,
const std::string& basedir,
Expand All @@ -248,7 +249,7 @@ class FileObjectOption : public ObjectOption

private:
std::string* const m_pointer;
boost::optional<std::string> m_default_value;
std::optional<std::string> m_default_value;
const std::vector<std::string> m_filter;
std::string m_basedir;

Expand All @@ -261,7 +262,7 @@ class ColorObjectOption : public ObjectOption
{
public:
ColorObjectOption(const std::string& text, Color* pointer, const std::string& key,
boost::optional<Color> default_value, bool use_alpha,
std::optional<Color> default_value, bool use_alpha,
unsigned int flags);

virtual void save(Writer& write) const override;
Expand All @@ -270,7 +271,7 @@ class ColorObjectOption : public ObjectOption

private:
Color* const m_pointer;
const boost::optional<Color> m_default_value;
const std::optional<Color> m_default_value;
bool m_use_alpha;

private:
Expand Down
Loading