mirror of
https://github.com/boostorg/optional.git
synced 2025-07-23 17:17:17 +02:00
boost::none - simpler and works with MSVC
This commit is contained in:
@ -22,8 +22,10 @@
|
||||
namespace boost {
|
||||
|
||||
#ifdef BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE
|
||||
|
||||
none_t const none = (static_cast<none_t>(0)) ;
|
||||
#else
|
||||
|
||||
#elif defined BOOST_OPTIONAL_USE_SINGLETON_DEFINITION_OF_NONE
|
||||
|
||||
namespace detail { namespace optional_detail {
|
||||
|
||||
@ -45,9 +47,13 @@ namespace {
|
||||
const none_t& none = detail::optional_detail::none_instance<none_t>::instance;
|
||||
}
|
||||
|
||||
#endif
|
||||
#else
|
||||
|
||||
const none_t none ((none_t::init_tag()));
|
||||
|
||||
#endif // older definitions
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
#endif // header guard
|
||||
|
||||
|
@ -16,13 +16,25 @@
|
||||
namespace boost {
|
||||
|
||||
#ifdef BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE
|
||||
|
||||
namespace detail { struct none_helper{}; }
|
||||
typedef int detail::none_helper::*none_t ;
|
||||
#else
|
||||
|
||||
#elif defined BOOST_OPTIONAL_USE_SINGLETON_DEFINITION_OF_NONE
|
||||
|
||||
class none_t {};
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
struct none_t
|
||||
{
|
||||
struct init_tag{};
|
||||
explicit none_t(init_tag){} // to prevent default constructor
|
||||
};
|
||||
|
||||
#endif // old implementation workarounds
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
#endif // header guard
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
#include <boost/none.hpp>
|
||||
#include "boost/none.hpp"
|
||||
#include "boost/optional/optional.hpp"
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ namespace boost
|
||||
template<class CharType, class CharTrait>
|
||||
inline
|
||||
std::basic_ostream<CharType, CharTrait>&
|
||||
operator<<(std::basic_ostream<CharType, CharTrait>& out, none_t const&)
|
||||
operator<<(std::basic_ostream<CharType, CharTrait>& out, none_t)
|
||||
{
|
||||
if (out.good())
|
||||
{
|
||||
|
Reference in New Issue
Block a user