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

            伊人热热久久原色播放www| 亚洲国产精品无码久久久不卡| 99久久久精品| 国产日韩久久免费影院| 一级做a爰片久久毛片毛片| 久久婷婷五月综合国产尤物app| 欧美亚洲色综久久精品国产| 99久久免费国产精精品| 久久久久这里只有精品 | 亚洲狠狠婷婷综合久久蜜芽| 久久精品国产亚洲AV嫖农村妇女| 久久久久久狠狠丁香| 久久中文字幕人妻熟av女| 久久人人爽人人爽人人片av高请| 99久久久久| 777米奇久久最新地址| 亚州日韩精品专区久久久| 久久最近最新中文字幕大全| 国产亚洲美女精品久久久2020| 国产精品无码久久四虎| 久久久精品国产免大香伊 | 色诱久久av| 亚洲国产精品热久久| 久久综合国产乱子伦精品免费| 久久精品亚洲男人的天堂| 久久久精品人妻一区二区三区蜜桃 | 四虎国产精品成人免费久久| 久久久中文字幕| 久久99国内精品自在现线| 色播久久人人爽人人爽人人片AV| 久久99国产精品二区不卡| 少妇内射兰兰久久| 久久精品国产亚洲AV蜜臀色欲 | 无码人妻精品一区二区三区久久久| 久久五月精品中文字幕| 99久久亚洲综合精品网站| 88久久精品无码一区二区毛片 | 久久精品国产一区| 久久免费视频网站| 国内精品久久久久久久亚洲 | 久久亚洲视频|