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

            久久精品国产72国产精福利| 国产成人综合久久精品红| 久久无码人妻一区二区三区午夜| 日韩精品无码久久久久久| 99久久精品国产毛片| 久久午夜福利无码1000合集| 久久国产精品久久久| 漂亮人妻被中出中文字幕久久| 国产精品久久免费| 国内精品久久久久影院薰衣草| 欧美久久精品一级c片片| 久久人妻AV中文字幕| 久久精品国产亚洲Aⅴ蜜臀色欲| 久久久久成人精品无码中文字幕| 久久久久久毛片免费看| 免费观看久久精彩视频| 日韩精品久久无码人妻中文字幕| 色老头网站久久网| 久久人搡人人玩人妻精品首页| 精品久久人妻av中文字幕| 亚洲乱码精品久久久久..| 无码八A片人妻少妇久久| 精品国产婷婷久久久| 久久青青草原综合伊人| 国产精品久久网| 久久精品草草草| 久久精品国产亚洲沈樵| 久久成人影院精品777| 久久青草国产精品一区| 99久久国语露脸精品国产| 久久久精品2019免费观看| 久久久久久久久久久久中文字幕| 热re99久久精品国99热| 亚洲va国产va天堂va久久| 乱亲女H秽乱长久久久| 精品无码久久久久久午夜| 国产高潮国产高潮久久久| 国产日产久久高清欧美一区| 久久九九有精品国产23百花影院| 好久久免费视频高清| 精品国产综合区久久久久久|