Fix std::optional related compilation errors on some platforms

This commit is contained in:
Jonathan G Rennison
2023-06-05 20:04:13 +01:00
parent 3d382fe531
commit ffb4548f1b
4 changed files with 6 additions and 4 deletions

View File

@@ -2549,7 +2549,7 @@ class LanguagePackGlyphSearcher : public MissingGlyphSearcher {
return FS_NORMAL; return FS_NORMAL;
} }
std::optional<std::string_view> NextString() override opt::optional<std::string_view> NextString() override
{ {
if (this->i >= TEXT_TAB_END) return std::nullopt; if (this->i >= TEXT_TAB_END) return std::nullopt;

View File

@@ -15,6 +15,7 @@
#include "gfx_type.h" #include "gfx_type.h"
#include "core/bitmath_func.hpp" #include "core/bitmath_func.hpp"
#include "vehicle_type.h" #include "vehicle_type.h"
#include "3rdparty/optional/ottd_optional.h"
/** /**
* Extract the StringTab from a StringID. * Extract the StringTab from a StringID.
@@ -266,7 +267,7 @@ public:
* Get the next string to search through. * Get the next string to search through.
* @return The next string or nullopt if there is none. * @return The next string or nullopt if there is none.
*/ */
virtual std::optional<std::string_view> NextString() = 0; virtual opt::optional<std::string_view> NextString() = 0;
/** /**
* Get the default (font) size of the string. * Get the default (font) size of the string.

View File

@@ -194,7 +194,7 @@ void TextfileWindow::SetupScrollbars(bool force_reflow)
return FS_MONO; return FS_MONO;
} }
/* virtual */ std::optional<std::string_view> TextfileWindow::NextString() /* virtual */ opt::optional<std::string_view> TextfileWindow::NextString()
{ {
if (this->search_iterator >= this->lines.size()) return std::nullopt; if (this->search_iterator >= this->lines.size()) return std::nullopt;

View File

@@ -14,6 +14,7 @@
#include "strings_func.h" #include "strings_func.h"
#include "textfile_type.h" #include "textfile_type.h"
#include "window_gui.h" #include "window_gui.h"
#include "3rdparty/optional/ottd_optional.h"
const char *GetTextfile(TextfileType type, Subdirectory dir, const char *filename); const char *GetTextfile(TextfileType type, Subdirectory dir, const char *filename);
@@ -36,7 +37,7 @@ struct TextfileWindow : public Window, MissingGlyphSearcher {
void Reset() override; void Reset() override;
FontSize DefaultSize() override; FontSize DefaultSize() override;
std::optional<std::string_view> NextString() override; opt::optional<std::string_view> NextString() override;
bool Monospace() override; bool Monospace() override;
void SetFontNames(FontCacheSettings *settings, const char *font_name, const void *os_data) override; void SetFontNames(FontCacheSettings *settings, const char *font_name, const void *os_data) override;