summaryrefslogtreecommitdiff
path: root/boost/none.hpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2015-04-08 03:09:47 +0000
committer <>2015-05-05 14:37:32 +0000
commitf2541bb90af059680aa7036f315f052175999355 (patch)
treea5b214744b256f07e1dc2bd7273035a7808c659f /boost/none.hpp
parented232fdd34968697a68783b3195b1da4226915b5 (diff)
downloadboost-tarball-master.tar.gz
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_58_0.tar.bz2.HEADboost_1_58_0master
Diffstat (limited to 'boost/none.hpp')
-rw-r--r--boost/none.hpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/boost/none.hpp b/boost/none.hpp
index e9fc0627f..87a6c707c 100644
--- a/boost/none.hpp
+++ b/boost/none.hpp
@@ -1,4 +1,5 @@
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
+// Copyright (C) 2014 Andrzej Krzemienski.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -20,7 +21,31 @@
namespace boost {
+#ifdef BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE
none_t const none = (static_cast<none_t>(0)) ;
+#else
+
+namespace detail { namespace optional_detail {
+
+ // the trick here is to make boost::none defined once as a global but in a header file
+ template <typename T>
+ struct none_instance
+ {
+ static const T instance;
+ };
+
+ template <typename T>
+ const T none_instance<T>::instance = T(); // global, but because 'tis a template, no cpp file required
+
+} } // namespace detail::optional_detail
+
+
+namespace {
+ // TU-local
+ const none_t& none = detail::optional_detail::none_instance<none_t>::instance;
+}
+
+#endif
} // namespace boost