X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=boost%2Fboost%2Fany.hpp;h=ad3f211f692284a362c06dd3131f19cb8008f38a;hb=b01a9dc187d9cd396a57463ad27511379dcdc9cd;hp=bda7f2efb1e8851f1cdc33992a39cabcda02358e;hpb=3dbc80c145f2e95326be0086f9492a09d0563a45;p=lyx.git diff --git a/boost/boost/any.hpp b/boost/boost/any.hpp index bda7f2efb1..ad3f211f69 100644 --- a/boost/boost/any.hpp +++ b/boost/boost/any.hpp @@ -1,3 +1,5 @@ +// See http://www.boost.org/libs/any for Documentation. + #ifndef BOOST_ANY_INCLUDED #define BOOST_ANY_INCLUDED @@ -12,6 +14,10 @@ #include #include "boost/config.hpp" +#include +#include +#include +#include namespace boost { @@ -130,6 +136,9 @@ namespace boost template friend ValueType * any_cast(any *); + template + friend ValueType * unsafe_any_cast(any *); + #else public: // representation (public so any_cast can be non-friend) @@ -167,20 +176,63 @@ namespace boost template ValueType any_cast(const any & operand) { - const ValueType * result = any_cast(&operand); + typedef BOOST_DEDUCED_TYPENAME remove_reference::type nonref; + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + // If 'nonref' is still reference type, it means the user has not + // specialized 'remove_reference'. + + // Please use BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION macro + // to generate specialization of remove_reference for your class + // See type traits library documentation for details + BOOST_STATIC_ASSERT(!is_reference::value); +#endif + + const nonref * result = any_cast(&operand); + if(!result) + boost::throw_exception(bad_any_cast()); + return *result; + } + + template + ValueType any_cast(any & operand) + { + typedef BOOST_DEDUCED_TYPENAME remove_reference::type nonref; + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + // The comment in the above version of 'any_cast' explains when this + // assert is fired and what to do. + BOOST_STATIC_ASSERT(!is_reference::value); +#endif + + nonref * result = any_cast(&operand); if(!result) - throw bad_any_cast(); + boost::throw_exception(bad_any_cast()); return *result; } + // Note: The "unsafe" versions of any_cast are not part of the + // public interface and may be removed at any time. They are + // required where we know what type is stored in the any and can't + // use typeid() comparison, e.g., when our types may travel across + // different shared libraries. + template + inline ValueType * unsafe_any_cast(any * operand) + { + return &static_cast *>(operand->content)->held; + } + + template + inline const ValueType * unsafe_any_cast(const any * operand) + { + return unsafe_any_cast(const_cast(operand)); + } } // Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved. // -// Permission to use, copy, modify, and distribute this software for any -// purpose is hereby granted without fee, provided that this copyright and -// permissions notice appear in all copies and derivatives. -// -// This software is provided "as is" without express or implied warranty. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) #endif