From 9ed20cb0854120f76d4ccc0f9821c38553574f7e Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Tue, 29 Oct 2019 21:21:03 +0300 Subject: [PATCH] Marked none instances as inline variables. This should avoid duplicating none instances in all translation units. Closes https://github.com/boostorg/optional/issues/33. --- include/boost/none.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/boost/none.hpp b/include/boost/none.hpp index a37c45c..b5df214 100644 --- a/include/boost/none.hpp +++ b/include/boost/none.hpp @@ -13,6 +13,7 @@ #ifndef BOOST_NONE_17SEP2003_HPP #define BOOST_NONE_17SEP2003_HPP +#include "boost/config.hpp" #include "boost/none_t.hpp" // NOTE: Borland users have to include this header outside any precompiled headers @@ -23,7 +24,7 @@ namespace boost { #ifdef BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE -none_t const none = (static_cast(0)) ; +BOOST_INLINE_VARIABLE none_t const none = (static_cast(0)) ; #elif defined BOOST_OPTIONAL_USE_SINGLETON_DEFINITION_OF_NONE @@ -35,7 +36,7 @@ namespace detail { namespace optional_detail { { static const T instance; }; - + template const T none_instance::instance = T(); // global, but because 'tis a template, no cpp file required @@ -49,7 +50,7 @@ namespace { #else -const none_t none ((none_t::init_tag())); +BOOST_INLINE_VARIABLE const none_t none ((none_t::init_tag())); #endif // older definitions