⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 systems.cpp

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 CPP
📖 第 1 页 / 共 5 页
字号:
BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,fluid_dram,volume)BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,teaspoon,volume)BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,tablespoon,volume)BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,fluid_ounce,volume)BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,gill,volume)BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,cup,volume)BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,pint,volume)BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,quart,volume)BOOST_UNITS_DEFINE_SINGLE_UNIT_SYSTEM(us,gallon,volume)#ifdef __GNUC__#include <cxxabi.h>#endifinline std::string demangle(const char* name){    #ifdef __GNUC__    // need to demangle C++ symbols    char*       realname;    std::size_t len;     int         stat;         realname = abi::__cxa_demangle(name,NULL,&len,&stat);        if (realname != NULL)    {        const std::string    out(realname);        free(realname);                return out;    }        return std::string("demangle :: error - unable to demangle specified symbol");    #else    return name;    #endif}int main(void){    using namespace boost::units;        {        using namespace boost::units::angle;                std::cout << "Testing angle base units..." << std::endl;                quantity<arcsecond_plane_angle>        as(1.0*arcseconds);        quantity<arcminute_plane_angle>        am(1.0*arcminutes);        quantity<degree_plane_angle>        d(1.0*degrees);        quantity<gradian_plane_angle>        g(1.0*gradians);        quantity<radian_plane_angle>        r(1.0*radians);        quantity<revolution_plane_angle>    rev(1.0*revolutions);                std::cout << as << " = " << quantity<si::plane_angle>(as) << std::endl                  << am << " = " << quantity<si::plane_angle>(am) << std::endl                  << d << " = " << quantity<si::plane_angle>(d) << std::endl                  << g << " = " << quantity<si::plane_angle>(g) << std::endl                  << r << " = " << quantity<si::plane_angle>(r) << std::endl                  << rev << " = " << quantity<si::plane_angle>(rev) << std::endl                  << std::endl;            std::cout << rev << "/" << as << " = " << quantity<si::dimensionless>(rev/as) << std::endl                  << rev << "/" << am << " = " << quantity<si::dimensionless>(rev/am) << std::endl                  << rev << "/" << d << " = " << quantity<si::dimensionless>(rev/d) << std::endl                  << rev << "/" << g << " = " << quantity<si::dimensionless>(rev/g) << std::endl                  << rev << "/" << r << " = " << quantity<si::dimensionless>(rev/r) << std::endl                  << std::endl;                          // conversions only work with exponent of +/- 1 in scaled_base_unit?        std::cout << as << " = " << quantity<arcsecond_plane_angle>(as) << std::endl                  << am << " = " << quantity<arcsecond_plane_angle>(am) << std::endl                  << d << " = " << quantity<arcsecond_plane_angle>(d) << std::endl                  << rev << " = " << quantity<arcsecond_plane_angle>(rev) << std::endl                  << std::endl;                          // conversions only work with exponent of +/- 1 in scaled_base_unit? see arcsecond.hpp        std::cout << as << " = " << quantity<arcminute_plane_angle>(as) << std::endl                  << am << " = " << quantity<arcminute_plane_angle>(am) << std::endl                  << d << " = " << quantity<arcminute_plane_angle>(d) << std::endl                  << rev << " = " << quantity<arcminute_plane_angle>(rev) << std::endl                  << std::endl;        std::cout << as << " = " << quantity<degree_plane_angle>(as) << std::endl                  << am << " = " << quantity<degree_plane_angle>(am) << std::endl                  << d << " = " << quantity<degree_plane_angle>(d) << std::endl                  << rev << " = " << quantity<degree_plane_angle>(rev) << std::endl                  << std::endl;                          std::cout << as << " = " << quantity<revolution_plane_angle>(as) << std::endl                  << am << " = " << quantity<revolution_plane_angle>(am) << std::endl                  << d << " = " << quantity<revolution_plane_angle>(d) << std::endl                  << rev << " = " << quantity<revolution_plane_angle>(rev) << std::endl                  << std::endl;                          quantity<steradian_solid_angle>        sa1(1.0*steradians);                std::cout << sa1 << std::endl                  << std::endl;    }        {        using namespace boost::units::astronomical;        std::cout << "Testing astronomical base units..." << std::endl;                quantity<light_second_length>        ls(1.0*light_seconds);        quantity<light_minute_length>        lm(1.0*light_minutes);        quantity<astronomical_unit_length>    au(1.0*astronomical_units);        quantity<light_hour_length>            lh(1.0*light_hours);        quantity<light_day_length>            ld(1.0*light_days);        quantity<light_year_length>            ly(1.0*light_years);        quantity<parsec_length>                ps(1.0*parsecs);                std::cout << ls << " = " << quantity<si::length>(ls) << std::endl                  << lm << " = " << quantity<si::length>(lm) << std::endl                  << au << " = " << quantity<si::length>(au) << std::endl                  << lh << " = " << quantity<si::length>(lh) << std::endl                  << ld << " = " << quantity<si::length>(ld) << std::endl                  << ly << " = " << quantity<si::length>(ly) << std::endl                  << ps << " = " << quantity<si::length>(ps) << std::endl                  << std::endl;                          std::cout << ly << "/" << ls << " = " << quantity<si::dimensionless>(ly/ls) << std::endl                  << ly << "/" << lm << " = " << quantity<si::dimensionless>(ly/lm) << std::endl                  << ly << "/" << au << " = " << quantity<si::dimensionless>(ly/au) << std::endl                  << ly << "/" << lh << " = " << quantity<si::dimensionless>(ly/ld) << std::endl                  << ly << "/" << ld << " = " << quantity<si::dimensionless>(ly/lh) << std::endl                  << ly << "/" << ps << " = " << quantity<si::dimensionless>(ly/ps) << std::endl                  << std::endl;                          std::cout << ls << " = " << quantity<light_second_length>(ls) << std::endl                  << lm << " = " << quantity<light_second_length>(lm) << std::endl                  << lh << " = " << quantity<light_second_length>(lh) << std::endl                  << ld << " = " << quantity<light_second_length>(ld) << std::endl                  << ly << " = " << quantity<light_second_length>(ly) << std::endl                  << std::endl;                          std::cout << ls << " = " << quantity<light_minute_length>(ls) << std::endl                  << lm << " = " << quantity<light_minute_length>(lm) << std::endl                  << lh << " = " << quantity<light_minute_length>(lh) << std::endl                  << ld << " = " << quantity<light_minute_length>(ld) << std::endl                  << ly << " = " << quantity<light_minute_length>(ly) << std::endl                  << std::endl;                          std::cout << ls << " = " << quantity<light_hour_length>(ls) << std::endl                  << lm << " = " << quantity<light_hour_length>(lm) << std::endl                  << lh << " = " << quantity<light_hour_length>(lh) << std::endl                  << ld << " = " << quantity<light_hour_length>(ld) << std::endl                  << ly << " = " << quantity<light_hour_length>(ly) << std::endl                  << std::endl;                          std::cout << ls << " = " << quantity<light_day_length>(ls) << std::endl                  << lm << " = " << quantity<light_day_length>(lm) << std::endl                  << lh << " = " << quantity<light_day_length>(lh) << std::endl                  << ld << " = " << quantity<light_day_length>(ld) << std::endl                  << ly << " = " << quantity<light_day_length>(ly) << std::endl                  << std::endl;                          std::cout << ls << " = " << quantity<light_year_length>(ls) << std::endl                  << lm << " = " << quantity<light_year_length>(lm) << std::endl                  << lh << " = " << quantity<light_year_length>(ld) << std::endl                  << ld << " = " << quantity<light_year_length>(lh) << std::endl                  << ly << " = " << quantity<light_year_length>(ly) << std::endl                  << std::endl;    }        {        using namespace boost::units::imperial;                std::cout << "Testing imperial base units..." << std::endl;                quantity<thou_length>            iml1(1.0*thous);        quantity<inch_length>            iml2(1.0*inchs);        quantity<foot_length>            iml3(1.0*foots);        quantity<yard_length>            iml4(1.0*yards);        quantity<furlong_length>        iml5(1.0*furlongs);        quantity<mile_length>            iml6(1.0*miles);        quantity<league_length>            iml7(1.0*leagues);                std::cout << iml1 << " = " << quantity<si::length>(iml1) << std::endl                  << iml2 << " = " << quantity<si::length>(iml2) << std::endl                  << iml3 << " = " << quantity<si::length>(iml3) << std::endl                  << iml4 << " = " << quantity<si::length>(iml4) << std::endl                  << iml5 << " = " << quantity<si::length>(iml5) << std::endl                  << iml6 << " = " << quantity<si::length>(iml6) << std::endl                  << iml7 << " = " << quantity<si::length>(iml7) << std::endl                  << std::endl;        std::cout << iml7 << "/" << iml1 << " = " << quantity<si::dimensionless>(iml7/iml1) << std::endl                  << iml7 << "/" << iml2 << " = " << quantity<si::dimensionless>(iml7/iml2) << std::endl                  << iml7 << "/" << iml3 << " = " << quantity<si::dimensionless>(iml7/iml3) << std::endl                  << iml7 << "/" << iml4 << " = " << quantity<si::dimensionless>(iml7/iml4) << std::endl                  << iml7 << "/" << iml5 << " = " << quantity<si::dimensionless>(iml7/iml5) << std::endl                  << iml7 << "/" << iml6 << " = " << quantity<si::dimensionless>(iml7/iml6) << std::endl                  << std::endl;                          std::cout << iml1 << " = " << quantity<thou_length>(iml1) << std::endl                  << iml2 << " = " << quantity<thou_length>(iml2) << std::endl                  << iml3 << " = " << quantity<thou_length>(iml3) << std::endl                  << iml4 << " = " << quantity<thou_length>(iml4) << std::endl                  << iml5 << " = " << quantity<thou_length>(iml5) << std::endl                  << iml6 << " = " << quantity<thou_length>(iml6) << std::endl                  << iml7 << " = " << quantity<thou_length>(iml7) << std::endl                  << std::endl;        std::cout << iml1 << " = " << quantity<inch_length>(iml1) << std::endl                  << iml2 << " = " << quantity<inch_length>(iml2) << std::endl                  << iml3 << " = " << quantity<inch_length>(iml3) << std::endl                  << iml4 << " = " << quantity<inch_length>(iml4) << std::endl                  << iml5 << " = " << quantity<inch_length>(iml5) << std::endl                  << iml6 << " = " << quantity<inch_length>(iml6) << std::endl                  << iml7 << " = " << quantity<inch_length>(iml7) << std::endl                  << std::endl;        std::cout << iml1 << " = " << quantity<foot_length>(iml1) << std::endl                  << iml2 << " = " << quantity<foot_length>(iml2) << std::endl                  << iml3 << " = " << quantity<foot_length>(iml3) << std::endl                  << iml4 << " = " << quantity<foot_length>(iml4) << std::endl                  << iml5 << " = " << quantity<foot_length>(iml5) << std::endl                  << iml6 << " = " << quantity<foot_length>(iml6) << std::endl

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -