• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 311, comments - 0, trackbacks - 0, articles - 0
              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理
            boost::unsafe_any_cast:類型強制轉換,不考慮原來的any的類型
                // 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<typename ValueType>
                inline ValueType 
            * unsafe_any_cast(any * operand)
                {
                    
            return &static_cast<any::holder<ValueType> *>(operand->content)->held;
                }

                template
            <typename ValueType>
                inline 
            const ValueType * unsafe_any_cast(const any * operand)
                {
                    
            return unsafe_any_cast<ValueType>(const_cast<any *>(operand));
                }

            boost::any_cast:必須和存的類型一致,否則報錯
                template<typename ValueType>
                ValueType 
            * any_cast(any * operand)
                {
                    
            return operand && 
            #ifdef BOOST_AUX_ANY_TYPE_ID_NAME
                        std::strcmp(operand
            ->type().name(), typeid(ValueType).name()) == 0
            #else
                        operand
            ->type() == typeid(ValueType)
            #endif
                        
            ? &static_cast<any::holder<ValueType> *>(operand->content)->held
                        : 
            0;
                }

                template
            <typename ValueType>
                inline 
            const ValueType * any_cast(const any * operand)
                {
                    
            return any_cast<ValueType>(const_cast<any *>(operand));
                }

                template
            <typename ValueType>
                ValueType any_cast(any 
            & operand)
                {
                    typedef BOOST_DEDUCED_TYPENAME remove_reference
            <ValueType>::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<nonref>::value);
            #endif

                    nonref 
            * result = any_cast<nonref>(&operand);
                    
            if(!result)
                        boost::throw_exception(bad_any_cast());
                    
            return *result;
                }

                template
            <typename ValueType>
                inline ValueType any_cast(
            const any & operand)
                {
                    typedef BOOST_DEDUCED_TYPENAME remove_reference
            <ValueType>::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<nonref>::value);
            #endif

                    
            return any_cast<const nonref &>(const_cast<any &>(operand));
                }
            用法:
            String abcd = "1.0";
            boost::any test 
            = abcd;
            float abc  =  boost::any_cast<float>(test);//報錯
            float abc1 = *boost::unsafe_any_cast<float>(&test);//結果也不對, 存什么類型,取出來必須強制轉換為什么類型

            97精品伊人久久大香线蕉app| 色播久久人人爽人人爽人人片AV| 国产精品99精品久久免费| 久久99热这里只有精品国产| 精品久久久久久无码专区不卡| 久久综合综合久久97色| 日本亚洲色大成网站WWW久久| 久久人人爽人人爽人人片AV麻烦 | 久久97久久97精品免视看| 亚洲午夜久久久| 久久人人爽人人爽人人片av高请| 国产精自产拍久久久久久蜜| 一本色道久久HEZYO无码| 99久久精品免费国产大片| 奇米影视7777久久精品人人爽| 97久久国产亚洲精品超碰热 | 国产一级持黄大片99久久| 国产精品激情综合久久| 亚洲∧v久久久无码精品| 久久99精品久久久久久水蜜桃| 久久狠狠高潮亚洲精品| 亚洲国产综合久久天堂| 国内精品久久久久久久亚洲| 久久久久人妻精品一区| 国产精品亚洲综合久久| 久久久久99精品成人片牛牛影视| 国内精品久久久久久久97牛牛| 2020久久精品亚洲热综合一本| 久久97久久97精品免视看| 狠狠色丁香婷婷综合久久来| 久久亚洲春色中文字幕久久久| 大香伊人久久精品一区二区| 日韩AV毛片精品久久久| 久久www免费人成看国产片| 天天久久狠狠色综合| 久久久中文字幕| 国产精品免费看久久久香蕉| 情人伊人久久综合亚洲| 51久久夜色精品国产| 久久精品免费大片国产大片| 久久精品国产亚洲Aⅴ香蕉|