• <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);//結果也不對, 存什么類型,取出來必須強制轉換為什么類型

            狠狠色狠狠色综合久久| 亚洲AV乱码久久精品蜜桃| 国产成人精品久久亚洲高清不卡 | 久久99精品国产麻豆不卡| 亚洲精品蜜桃久久久久久| 香蕉久久一区二区不卡无毒影院| 三级片免费观看久久| 国内精品久久久久久99蜜桃 | 久久人人青草97香蕉| 久久99国产综合精品| 亚洲欧洲久久av| 久久99精品国产麻豆婷婷| 狠狠色婷婷久久一区二区三区| 久久久无码精品午夜| 一级做a爰片久久毛片16| 久久久久人妻精品一区二区三区 | 国内精品久久久久久久久| 久久天天躁狠狠躁夜夜网站| 久久久精品日本一区二区三区| 国产精品久久永久免费| 久久婷婷成人综合色综合| 一本久久a久久精品亚洲| 模特私拍国产精品久久| 欧美激情精品久久久久久久九九九| 国产精品久久久久9999高清| 国产精品久久久久免费a∨| 人人狠狠综合88综合久久| 久久婷婷人人澡人人| 日韩精品无码久久一区二区三| 久久久久久噜噜精品免费直播| 九九久久精品无码专区| 青青久久精品国产免费看| 久久精品无码av| 伊人伊成久久人综合网777| 久久精品桃花综合| 亚洲欧美国产精品专区久久| 狠狠色丁香婷婷久久综合| 久久久久久久波多野结衣高潮 | 精品久久久久久无码中文字幕 | 国产精品久久新婚兰兰| 中文字幕无码免费久久|