Skip to content

Commit

Permalink
Marked none instances as inline variables.
Browse files Browse the repository at this point in the history
This should avoid duplicating none instances in all translation units.

Closes boostorg#33.
  • Loading branch information
Lastique committed Oct 29, 2019
1 parent 29dfc17 commit 1f84919
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions include/boost/none.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#ifndef BOOST_NONE_17SEP2003_HPP
#define BOOST_NONE_17SEP2003_HPP

#include "boost/none_t.hpp"
#include <boost/config.hpp>
#include <boost/none_t.hpp>

// NOTE: Borland users have to include this header outside any precompiled headers
// (bcc<=5.64 cannot include instance data in a precompiled header)
Expand All @@ -23,7 +24,7 @@ namespace boost {

#ifdef BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE

none_t const none = (static_cast<none_t>(0)) ;
BOOST_INLINE_VARIABLE none_t const none = (static_cast<none_t>(0)) ;

#elif defined BOOST_OPTIONAL_USE_SINGLETON_DEFINITION_OF_NONE

Expand All @@ -35,7 +36,7 @@ namespace detail { namespace optional_detail {
{
static const T instance;
};

template <typename T>
const T none_instance<T>::instance = T(); // global, but because 'tis a template, no cpp file required

Expand All @@ -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

Expand Down

0 comments on commit 1f84919

Please sign in to comment.