1 // Copyright (C) 2003, Fernando Luis Cacciola Carballal. 2 // Copyright (C) 2014 Andrzej Krzemienski. 3 // 4 // Distributed under the Boost Software License, Version 1.0. 5 // (See accompanying file LICENSE_1_0.txt or copy at 6 // http://www.boost.org/LICENSE_1_0.txt) 7 // 8 // See http://www.boost.org/libs/optional for documentation. 9 // 10 // You are welcome to contact the author at: 11 // fernando_cacciola@hotmail.com 12 // 13 #ifndef BOOST_NONE_17SEP2003_HPP 14 #define BOOST_NONE_17SEP2003_HPP 15 16 #include "boost/none_t.hpp" 17 18 // NOTE: Borland users have to include this header outside any precompiled headers 19 // (bcc<=5.64 cannot include instance data in a precompiled header) 20 // -- * To be verified, now that there's no unnamed namespace 21 22 namespace boost { 23 24 #ifdef BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE 25 none_t const none = (static_cast<none_t>(0)) ; 26 #else 27 28 namespace detail { namespace optional_detail { 29 30 // the trick here is to make boost::none defined once as a global but in a header file 31 template <typename T> 32 struct none_instance 33 { 34 static const T instance; 35 }; 36 37 template <typename T> 38 const T none_instance<T>::instance = T(); // global, but because 'tis a template, no cpp file required 39 40 } } // namespace detail::optional_detail 41 42 43 namespace { 44 // TU-local 45 const none_t& none = detail::optional_detail::none_instance<none_t>::instance; 46 } 47 48 #endif 49 50 } // namespace boost 51 52 #endif 53 54