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

            久久综合亚洲欧美成人| 亚洲精品综合久久| 精品人妻伦九区久久AAA片69| 天天爽天天爽天天片a久久网| 亚洲午夜久久久久久久久电影网| 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 久久精品国产只有精品66| 久久精品国产亚洲欧美| 国产精品一久久香蕉国产线看观看| 亚洲精品高清一二区久久| 理论片午午伦夜理片久久 | 亚洲精品tv久久久久久久久久| 久久久精品视频免费观看| 国内精品久久久久久麻豆| 国产女人aaa级久久久级| 久久国产精品偷99| 久久久久无码专区亚洲av| 久久久久久毛片免费看| 久久久WWW成人免费精品| 人人狠狠综合久久亚洲高清| 人妻少妇精品久久| 一本一本久久a久久综合精品蜜桃| 中文字幕人妻色偷偷久久| 久久人人爽人人爽人人片AV不 | 99久久99久久精品国产片果冻| av色综合久久天堂av色综合在| 久久精品a亚洲国产v高清不卡| 精品久久久久久国产91| 久久久久久无码国产精品中文字幕| 热99RE久久精品这里都是精品免费| 亚洲午夜久久久久久久久电影网 | 亚洲色婷婷综合久久| 久久久久久人妻无码| 精品久久久久中文字| 久久天天躁狠狠躁夜夜avapp| 久久国产亚洲高清观看| 青青青国产成人久久111网站| 女同久久| 亚洲国产精品久久| 精品久久久一二三区| 国产∨亚洲V天堂无码久久久|