I'd like to define some constants in a c++ program. The excellent boost library has them predefined, and I like to assign my constants these values, eg something like
#include <iostream>
#include <boost/units/systems/si/codata/electromagnetic_constants.hpp>
int main(int argc, const char * argv[]) {
double electron_charge = boost::units::si::constants::codata::e;
std::cout << electron_charge << std::endl;
return 0;
}
But this does not work since boost's e is not of type double
but of type value_type
. How can I access the value in double precision?
您需要将电子的电荷除以电荷单位:库仑:
double electron_charge = boost::units::si::constants::codata::e / boost::units::si::coulomb;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.