X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=boost%2Fboost%2Fany.hpp;h=ad3f211f692284a362c06dd3131f19cb8008f38a;hb=b01a9dc187d9cd396a57463ad27511379dcdc9cd;hp=5587aa6e41a1f235321693083f1d15b59e075bc0;hpb=fa06f3acc21a2035e115ef5d47adfd08c9494ff6;p=lyx.git diff --git a/boost/boost/any.hpp b/boost/boost/any.hpp index 5587aa6e41..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 { @@ -82,7 +88,7 @@ namespace boost class placeholder { public: // structors - + virtual ~placeholder() { } @@ -92,7 +98,7 @@ namespace boost virtual const std::type_info & type() const = 0; virtual placeholder * clone() const = 0; - + }; template @@ -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