prefixes.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Boost.Units - A C++ library for zero-overhead dimensional analysis and
  2. // unit/quantity manipulation and conversion
  3. //
  4. // Copyright (C) 2014 Erik Erlandson
  5. //
  6. // Distributed under the Boost Software License, Version 1.0. (See
  7. // accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. #ifndef BOOST_UNITS_SYSTEMS_INFORMATION_PREFIXES_HPP_INCLUDED
  10. #define BOOST_UNITS_SYSTEMS_INFORMATION_PREFIXES_HPP_INCLUDED
  11. #include <boost/units/make_scaled_unit.hpp>
  12. #include <boost/units/static_rational.hpp>
  13. #include <boost/units/scale.hpp>
  14. #include <boost/units/systems/information/byte.hpp>
  15. #define BOOST_UNITS_INFOSYS_PREFIX(exponent, name) \
  16. typedef make_scaled_unit<dimensionless, scale<2, static_rational<exponent> > >::type name ## _pf_type; \
  17. BOOST_UNITS_STATIC_CONSTANT(name, name ## _pf_type)
  18. namespace boost {
  19. namespace units {
  20. namespace information {
  21. // Note, these are defined (somewhat arbitrarily) against the 'byte' system.
  22. // They work smoothly with bit_information, nat_information, etc, so it is
  23. // transparent to the user.
  24. BOOST_UNITS_INFOSYS_PREFIX(10, kibi);
  25. BOOST_UNITS_INFOSYS_PREFIX(20, mebi);
  26. BOOST_UNITS_INFOSYS_PREFIX(30, gibi);
  27. BOOST_UNITS_INFOSYS_PREFIX(40, tebi);
  28. BOOST_UNITS_INFOSYS_PREFIX(50, pebi);
  29. BOOST_UNITS_INFOSYS_PREFIX(60, exbi);
  30. BOOST_UNITS_INFOSYS_PREFIX(70, zebi);
  31. BOOST_UNITS_INFOSYS_PREFIX(80, yobi);
  32. } // namespace information
  33. } // namespace units
  34. } // namespace boost
  35. #undef BOOST_UNITS_INFOSYS_PREFIX
  36. #endif // BOOST_UNITS_SYSTEMS_INFORMATION_PREFIXES_HPP_INCLUDED