zoukankan      html  css  js  c++  java
  • Boost Conversion Library polymorphic_cast polymorphic_downcast lexical_cast

    #include <boost/cast.hpp> 

    polymorphic_cast polymorphic_downcast

    <boost/lexical_cast.hpp>

    lexical_cast bad_lexical_cast

    int main(int argc, char * argv[])
    {
        using boost::lexical_cast;
        using boost::bad_lexical_cast;
    
        std::vector<short> args;
    
        while(*++argv)
        {
            try
            {
                args.push_back(lexical_cast<short>(*argv));
            }
            catch(bad_lexical_cast &)
            {
                args.push_back(0);
            }
        }
        ...
    }

    For more involved conversions, such as where precision or formatting need tighter control than is offered by the default behavior of lexical_cast, the conventional std::stringstream approach is recommended. Where the conversions are numeric to numeric, boost::numeric_cast may offer more reasonable behavior than lexical_cast.
  • 相关阅读:
    错误设置子网掩码的结果
    子网掩码
    网络笔记
    网络笔记
    命名空间
    命名空间
    多重继承和虚继承
    多重继承和虚继承
    windows抓包程序
    windows抓包程序
  • 原文地址:https://www.cnblogs.com/logitechlike/p/2835448.html
Copyright © 2011-2022 走看看