Ticket #9462: 0001-Fix-issue-9462-with-returning-rvalue-reference-inste.patch

File 0001-Fix-issue-9462-with-returning-rvalue-reference-inste.patch, 2.6 KB (added by Antony Polukhin, 9 years ago)
  • doc/any.xml

    From 2d5c7f3be70e6e438df7dca64f8876a5a5ede7ee Mon Sep 17 00:00:00 2001
    From: Antony Polukhin <antoshkka@gmail.com>
    Date: Tue, 3 Dec 2013 16:42:25 +0400
    Subject: [PATCH] Fix issue #9462 with returning rvalue reference instead of
     returning by copy
    
    ---
     doc/any.xml           | 14 +++++++++++++-
     include/boost/any.hpp | 17 +++--------------
     2 files changed, 16 insertions(+), 15 deletions(-)
    
    diff --git a/doc/any.xml b/doc/any.xml
    index 0f2f9ac..92944cc 100644
    a b public:  
    499499              <paramtype><classname>any</classname> &amp;</paramtype>
    500500            </parameter>
    501501          </signature>
    502          
     502
     503          <signature>
     504            <template>
     505              <template-type-parameter name="T"/>
     506            </template>
     507
     508            <type>T</type>
     509
     510            <parameter name="operand">
     511              <paramtype><classname>any</classname> &amp;&amp;</paramtype>
     512            </parameter>
     513          </signature>
     514
    503515          <signature>
    504516            <template>
    505517              <template-type-parameter name="T"/>
  • include/boost/any.hpp

    diff --git a/include/boost/any.hpp b/include/boost/any.hpp
    index 44cfd0a..3798952 100644
    a b  
    4040#include <cstring>
    4141# endif
    4242
    43 #if defined(_MSC_VER)
    44 #pragma warning(push)
    45 #pragma warning(disable: 4172) // Mistakenly warns: returning address of local variable or temporary
    46 #endif
    47 
    4843namespace boost
    4944{
    5045    class any
    namespace boost  
    293288    inline ValueType any_cast(const any & operand)
    294289    {
    295290        typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref;
    296 
    297 
    298291        return any_cast<const nonref &>(const_cast<any &>(operand));
    299292    }
    300293
    301294#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
    302295    template<typename ValueType>
    303     inline ValueType&& any_cast(any&& operand)
     296    inline ValueType any_cast(any&& operand)
    304297    {
    305298        BOOST_STATIC_ASSERT_MSG(
    306             boost::is_rvalue_reference<ValueType&&>::value
     299            boost::is_rvalue_reference<ValueType&&>::value /*true if ValueType is rvalue or just a value*/
    307300            || boost::is_const< typename boost::remove_reference<ValueType>::type >::value,
    308301            "boost::any_cast shall not be used for getting nonconst references to temporary objects"
    309302        );
    310         return any_cast<ValueType&&>(operand);
     303        return any_cast<ValueType>(operand);
    311304    }
    312305#endif
    313306
    namespace boost  
    336329// accompanying file LICENSE_1_0.txt or copy at
    337330// http://www.boost.org/LICENSE_1_0.txt)
    338331
    339 #if defined(_MSC_VER)
    340 #pragma warning(pop)
    341 #endif
    342 
    343332#endif