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