The Battle for Wesnoth  1.19.9+dev
optional_fwd.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2020 - 2025
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 #ifndef __APPLE__
18 #include <optional>
19 #else
20 #include <boost/optional.hpp>
21 #endif
22 
23 namespace utils
24 {
25 #ifndef __APPLE__
26 
27 using std::optional;
28 using std::make_optional;
29 using std::nullopt;
30 using std::nullopt_t;
31 using std::bad_optional_access;
32 
33 #else
34 
35 using boost::optional;
36 using boost::make_optional;
37 using boost::bad_optional_access;
38 using nullopt_t = boost::none_t;
39 
40 // Create a new nullopt object equivalent to boost::none to match the STL interface
41 static const boost::none_t nullopt{boost::none_t::init_tag{}};
42 
43 #endif
44 
45 } // end namespace utils