ratio_io.hpp 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342
  1. // ratio_io
  2. //
  3. // (C) Copyright Howard Hinnant
  4. // (C) Copyright 2010 Vicente J. Botet Escriba
  5. // Use, modification and distribution are subject to the Boost Software License,
  6. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt).
  8. //
  9. // This code was adapted by Vicente from Howard Hinnant's experimental work
  10. // on chrono i/o under lvm/libc++ to Boost
  11. #ifndef BOOST_RATIO_DETAIL_RATIO_IO_HPP
  12. #define BOOST_RATIO_DETAIL_RATIO_IO_HPP
  13. /*
  14. ratio_io synopsis
  15. #include <ratio>
  16. #include <string>
  17. namespace boost
  18. {
  19. template <class Ratio, class CharT>
  20. struct ratio_string
  21. {
  22. static basic_string<CharT> short_name();
  23. static basic_string<CharT> long_name();
  24. };
  25. } // boost
  26. */
  27. #include <boost/config.hpp>
  28. #include <boost/ratio/ratio.hpp>
  29. #include <boost/type_traits/integral_constant.hpp>
  30. #include <string>
  31. #include <sstream>
  32. #if defined(BOOST_NO_CXX11_UNICODE_LITERALS) || defined(BOOST_NO_CXX11_CHAR16_T) || defined(BOOST_NO_CXX11_CHAR32_T) || defined(BOOST_NO_CXX11_U16STRING) || defined(BOOST_NO_CXX11_U32STRING)
  33. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  34. #undef BOOST_RATIO_HAS_UNICODE_SUPPORT
  35. #endif
  36. #else
  37. #define BOOST_RATIO_HAS_UNICODE_SUPPORT 1
  38. #endif
  39. namespace boost {
  40. //template <class Ratio>
  41. //struct ratio_string_is_localizable : false_type {};
  42. //template <class Ratio>
  43. //struct ratio_string_id : integral_constant<int,0> {};
  44. template <class Ratio, class CharT>
  45. struct ratio_string
  46. {
  47. static std::basic_string<CharT> short_name() {return long_name();}
  48. static std::basic_string<CharT> long_name();
  49. static std::basic_string<CharT> symbol() {return short_name();}
  50. static std::basic_string<CharT> prefix() {return long_name();}
  51. };
  52. template <class Ratio, class CharT>
  53. std::basic_string<CharT>
  54. ratio_string<Ratio, CharT>::long_name()
  55. {
  56. std::basic_ostringstream<CharT> os;
  57. os << CharT('[') << Ratio::num << CharT('/')
  58. << Ratio::den << CharT(']');
  59. return os.str();
  60. }
  61. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  62. namespace ratio_detail {
  63. template <class Ratio, class CharT>
  64. struct ratio_string_static
  65. {
  66. static std::string short_name() {
  67. return std::basic_string<CharT>(
  68. static_string::c_str<
  69. typename ratio_static_string<Ratio, CharT>::short_name
  70. >::value);
  71. }
  72. static std::string long_name() {
  73. return std::basic_string<CharT>(
  74. static_string::c_str<
  75. typename ratio_static_string<Ratio, CharT>::long_name
  76. >::value);
  77. }
  78. static std::basic_string<CharT> symbol() {return short_name();}
  79. static std::basic_string<CharT> prefix() {return long_name();}
  80. };
  81. }
  82. #endif
  83. // atto
  84. //template <>
  85. //struct ratio_string_is_localizable<atto> : true_type {};
  86. //
  87. //template <>
  88. //struct ratio_string_id<atto> : integral_constant<int,-18> {};
  89. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  90. template <typename CharT>
  91. struct ratio_string<atto, CharT> :
  92. ratio_detail::ratio_string_static<atto,CharT>
  93. {};
  94. #else
  95. template <>
  96. struct ratio_string<atto, char>
  97. {
  98. static std::string short_name() {return std::string(1, 'a');}
  99. static std::string long_name() {return std::string("atto");}
  100. static std::string symbol() {return short_name();}
  101. static std::string prefix() {return long_name();}
  102. };
  103. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  104. template <>
  105. struct ratio_string<atto, char16_t>
  106. {
  107. static std::u16string short_name() {return std::u16string(1, u'a');}
  108. static std::u16string long_name() {return std::u16string(u"atto");}
  109. static std::u16string symbol() {return short_name();}
  110. static std::u16string prefix() {return long_name();}
  111. };
  112. template <>
  113. struct ratio_string<atto, char32_t>
  114. {
  115. static std::u32string short_name() {return std::u32string(1, U'a');}
  116. static std::u32string long_name() {return std::u32string(U"atto");}
  117. static std::u32string symbol() {return short_name();}
  118. static std::u32string prefix() {return long_name();}
  119. };
  120. #endif
  121. #ifndef BOOST_NO_STD_WSTRING
  122. template <>
  123. struct ratio_string<atto, wchar_t>
  124. {
  125. static std::wstring short_name() {return std::wstring(1, L'a');}
  126. static std::wstring long_name() {return std::wstring(L"atto");}
  127. static std::wstring symbol() {return short_name();}
  128. static std::wstring prefix() {return long_name();}
  129. };
  130. #endif
  131. #endif
  132. // femto
  133. //template <>
  134. //struct ratio_string_is_localizable<femto> : true_type {};
  135. //
  136. //template <>
  137. //struct ratio_string_id<femto> : integral_constant<int,-15> {};
  138. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  139. template <typename CharT>
  140. struct ratio_string<femto, CharT> :
  141. ratio_detail::ratio_string_static<femto,CharT>
  142. {};
  143. #else
  144. template <>
  145. struct ratio_string<femto, char>
  146. {
  147. static std::string short_name() {return std::string(1, 'f');}
  148. static std::string long_name() {return std::string("femto");}
  149. static std::string symbol() {return short_name();}
  150. static std::string prefix() {return long_name();}
  151. };
  152. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  153. template <>
  154. struct ratio_string<femto, char16_t>
  155. {
  156. static std::u16string short_name() {return std::u16string(1, u'f');}
  157. static std::u16string long_name() {return std::u16string(u"femto");}
  158. static std::u16string symbol() {return short_name();}
  159. static std::u16string prefix() {return long_name();}
  160. };
  161. template <>
  162. struct ratio_string<femto, char32_t>
  163. {
  164. static std::u32string short_name() {return std::u32string(1, U'f');}
  165. static std::u32string long_name() {return std::u32string(U"femto");}
  166. static std::u32string symbol() {return short_name();}
  167. static std::u32string prefix() {return long_name();}
  168. };
  169. #endif
  170. #ifndef BOOST_NO_STD_WSTRING
  171. template <>
  172. struct ratio_string<femto, wchar_t>
  173. {
  174. static std::wstring short_name() {return std::wstring(1, L'f');}
  175. static std::wstring long_name() {return std::wstring(L"femto");}
  176. static std::wstring symbol() {return short_name();}
  177. static std::wstring prefix() {return long_name();}
  178. };
  179. #endif
  180. #endif
  181. // pico
  182. //template <>
  183. //struct ratio_string_is_localizable<pico> : true_type {};
  184. //
  185. //template <>
  186. //struct ratio_string_id<pico> : integral_constant<int,-12> {};
  187. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  188. template <typename CharT>
  189. struct ratio_string<pico, CharT> :
  190. ratio_detail::ratio_string_static<pico,CharT>
  191. {};
  192. #else
  193. template <>
  194. struct ratio_string<pico, char>
  195. {
  196. static std::string short_name() {return std::string(1, 'p');}
  197. static std::string long_name() {return std::string("pico");}
  198. static std::string symbol() {return short_name();}
  199. static std::string prefix() {return long_name();}
  200. };
  201. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  202. template <>
  203. struct ratio_string<pico, char16_t>
  204. {
  205. static std::u16string short_name() {return std::u16string(1, u'p');}
  206. static std::u16string long_name() {return std::u16string(u"pico");}
  207. static std::u16string symbol() {return short_name();}
  208. static std::u16string prefix() {return long_name();}
  209. };
  210. template <>
  211. struct ratio_string<pico, char32_t>
  212. {
  213. static std::u32string short_name() {return std::u32string(1, U'p');}
  214. static std::u32string long_name() {return std::u32string(U"pico");}
  215. static std::u32string symbol() {return short_name();}
  216. static std::u32string prefix() {return long_name();}
  217. };
  218. #endif
  219. #ifndef BOOST_NO_STD_WSTRING
  220. template <>
  221. struct ratio_string<pico, wchar_t>
  222. {
  223. static std::wstring short_name() {return std::wstring(1, L'p');}
  224. static std::wstring long_name() {return std::wstring(L"pico");}
  225. static std::wstring symbol() {return short_name();}
  226. static std::wstring prefix() {return long_name();}
  227. };
  228. #endif
  229. #endif
  230. // nano
  231. //template <>
  232. //struct ratio_string_is_localizable<nano> : true_type {};
  233. //
  234. //template <>
  235. //struct ratio_string_id<nano> : integral_constant<int,-9> {};
  236. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  237. template <typename CharT>
  238. struct ratio_string<nano, CharT> :
  239. ratio_detail::ratio_string_static<nano,CharT>
  240. {};
  241. #else
  242. template <>
  243. struct ratio_string<nano, char>
  244. {
  245. static std::string short_name() {return std::string(1, 'n');}
  246. static std::string long_name() {return std::string("nano");}
  247. static std::string symbol() {return short_name();}
  248. static std::string prefix() {return long_name();}
  249. };
  250. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  251. template <>
  252. struct ratio_string<nano, char16_t>
  253. {
  254. static std::u16string short_name() {return std::u16string(1, u'n');}
  255. static std::u16string long_name() {return std::u16string(u"nano");}
  256. static std::u16string symbol() {return short_name();}
  257. static std::u16string prefix() {return long_name();}
  258. };
  259. template <>
  260. struct ratio_string<nano, char32_t>
  261. {
  262. static std::u32string short_name() {return std::u32string(1, U'n');}
  263. static std::u32string long_name() {return std::u32string(U"nano");}
  264. static std::u32string symbol() {return short_name();}
  265. static std::u32string prefix() {return long_name();}
  266. };
  267. #endif
  268. #ifndef BOOST_NO_STD_WSTRING
  269. template <>
  270. struct ratio_string<nano, wchar_t>
  271. {
  272. static std::wstring short_name() {return std::wstring(1, L'n');}
  273. static std::wstring long_name() {return std::wstring(L"nano");}
  274. static std::wstring symbol() {return short_name();}
  275. static std::wstring prefix() {return long_name();}
  276. };
  277. #endif
  278. #endif
  279. // micro
  280. //template <>
  281. //struct ratio_string_is_localizable<micro> : true_type {};
  282. //
  283. //template <>
  284. //struct ratio_string_id<micro> : integral_constant<int,-6> {};
  285. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  286. template <typename CharT>
  287. struct ratio_string<micro, CharT> :
  288. ratio_detail::ratio_string_static<micro,CharT>
  289. {};
  290. #else
  291. template <>
  292. struct ratio_string<micro, char>
  293. {
  294. static std::string short_name() {return std::string("\xC2\xB5");}
  295. static std::string long_name() {return std::string("micro");}
  296. static std::string symbol() {return short_name();}
  297. static std::string prefix() {return long_name();}
  298. };
  299. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  300. template <>
  301. struct ratio_string<micro, char16_t>
  302. {
  303. static std::u16string short_name() {return std::u16string(1, u'\xB5');}
  304. static std::u16string long_name() {return std::u16string(u"micro");}
  305. static std::u16string symbol() {return short_name();}
  306. static std::u16string prefix() {return long_name();}
  307. };
  308. template <>
  309. struct ratio_string<micro, char32_t>
  310. {
  311. static std::u32string short_name() {return std::u32string(1, U'\xB5');}
  312. static std::u32string long_name() {return std::u32string(U"micro");}
  313. static std::u32string symbol() {return short_name();}
  314. static std::u32string prefix() {return long_name();}
  315. };
  316. #endif
  317. #ifndef BOOST_NO_STD_WSTRING
  318. template <>
  319. struct ratio_string<micro, wchar_t>
  320. {
  321. static std::wstring short_name() {return std::wstring(1, L'\xB5');}
  322. static std::wstring long_name() {return std::wstring(L"micro");}
  323. static std::wstring symbol() {return short_name();}
  324. static std::wstring prefix() {return long_name();}
  325. };
  326. #endif
  327. #endif
  328. // milli
  329. //template <>
  330. //struct ratio_string_is_localizable<milli> : true_type {};
  331. //
  332. //template <>
  333. //struct ratio_string_id<milli> : integral_constant<int,-3> {};
  334. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  335. template <typename CharT>
  336. struct ratio_string<milli, CharT> :
  337. ratio_detail::ratio_string_static<milli,CharT>
  338. {};
  339. #else
  340. template <>
  341. struct ratio_string<milli, char>
  342. {
  343. static std::string short_name() {return std::string(1, 'm');}
  344. static std::string long_name() {return std::string("milli");}
  345. static std::string symbol() {return short_name();}
  346. static std::string prefix() {return long_name();}
  347. };
  348. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  349. template <>
  350. struct ratio_string<milli, char16_t>
  351. {
  352. static std::u16string short_name() {return std::u16string(1, u'm');}
  353. static std::u16string long_name() {return std::u16string(u"milli");}
  354. static std::u16string symbol() {return short_name();}
  355. static std::u16string prefix() {return long_name();}
  356. };
  357. template <>
  358. struct ratio_string<milli, char32_t>
  359. {
  360. static std::u32string short_name() {return std::u32string(1, U'm');}
  361. static std::u32string long_name() {return std::u32string(U"milli");}
  362. static std::u32string symbol() {return short_name();}
  363. static std::u32string prefix() {return long_name();}
  364. };
  365. #endif
  366. #ifndef BOOST_NO_STD_WSTRING
  367. template <>
  368. struct ratio_string<milli, wchar_t>
  369. {
  370. static std::wstring short_name() {return std::wstring(1, L'm');}
  371. static std::wstring long_name() {return std::wstring(L"milli");}
  372. static std::wstring symbol() {return short_name();}
  373. static std::wstring prefix() {return long_name();}
  374. };
  375. #endif
  376. #endif
  377. // centi
  378. //template <>
  379. //struct ratio_string_is_localizable<centi> : true_type {};
  380. //
  381. //template <>
  382. //struct ratio_string_id<centi> : integral_constant<int,-2> {};
  383. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  384. template <typename CharT>
  385. struct ratio_string<centi, CharT> :
  386. ratio_detail::ratio_string_static<centi,CharT>
  387. {};
  388. #else
  389. template <>
  390. struct ratio_string<centi, char>
  391. {
  392. static std::string short_name() {return std::string(1, 'c');}
  393. static std::string long_name() {return std::string("centi");}
  394. static std::string symbol() {return short_name();}
  395. static std::string prefix() {return long_name();}
  396. };
  397. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  398. template <>
  399. struct ratio_string<centi, char16_t>
  400. {
  401. static std::u16string short_name() {return std::u16string(1, u'c');}
  402. static std::u16string long_name() {return std::u16string(u"centi");}
  403. static std::u16string symbol() {return short_name();}
  404. static std::u16string prefix() {return long_name();}
  405. };
  406. template <>
  407. struct ratio_string<centi, char32_t>
  408. {
  409. static std::u32string short_name() {return std::u32string(1, U'c');}
  410. static std::u32string long_name() {return std::u32string(U"centi");}
  411. static std::u32string symbol() {return short_name();}
  412. static std::u32string prefix() {return long_name();}
  413. };
  414. #endif
  415. #ifndef BOOST_NO_STD_WSTRING
  416. template <>
  417. struct ratio_string<centi, wchar_t>
  418. {
  419. static std::wstring short_name() {return std::wstring(1, L'c');}
  420. static std::wstring long_name() {return std::wstring(L"centi");}
  421. static std::wstring symbol() {return short_name();}
  422. static std::wstring prefix() {return long_name();}
  423. };
  424. #endif
  425. #endif
  426. // deci
  427. //template <>
  428. //struct ratio_string_is_localizable<deci> : true_type {};
  429. //
  430. //template <>
  431. //struct ratio_string_id<deci> : integral_constant<int,-1> {};
  432. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  433. template <typename CharT>
  434. struct ratio_string<deci, CharT> :
  435. ratio_detail::ratio_string_static<deci,CharT>
  436. {};
  437. #else
  438. template <>
  439. struct ratio_string<deci, char>
  440. {
  441. static std::string short_name() {return std::string(1, 'd');}
  442. static std::string long_name() {return std::string("deci");}
  443. static std::string symbol() {return short_name();}
  444. static std::string prefix() {return long_name();}
  445. };
  446. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  447. template <>
  448. struct ratio_string<deci, char16_t>
  449. {
  450. static std::u16string short_name() {return std::u16string(1, u'd');}
  451. static std::u16string long_name() {return std::u16string(u"deci");}
  452. static std::u16string symbol() {return short_name();}
  453. static std::u16string prefix() {return long_name();}
  454. };
  455. template <>
  456. struct ratio_string<deci, char32_t>
  457. {
  458. static std::u32string short_name() {return std::u32string(1, U'd');}
  459. static std::u32string long_name() {return std::u32string(U"deci");}
  460. static std::u32string symbol() {return short_name();}
  461. static std::u32string prefix() {return long_name();}
  462. };
  463. #endif
  464. #ifndef BOOST_NO_STD_WSTRING
  465. template <>
  466. struct ratio_string<deci, wchar_t>
  467. {
  468. static std::wstring short_name() {return std::wstring(1, L'd');}
  469. static std::wstring long_name() {return std::wstring(L"deci");}
  470. static std::wstring symbol() {return short_name();}
  471. static std::wstring prefix() {return long_name();}
  472. };
  473. #endif
  474. #endif
  475. // unit
  476. //template <>
  477. //struct ratio_string_is_localizable<ratio<1> > : true_type {};
  478. //
  479. //template <>
  480. //struct ratio_string_id<ratio<1> > : integral_constant<int,0> {};
  481. // deca
  482. //template <>
  483. //struct ratio_string_is_localizable<deca> : true_type {};
  484. //
  485. //template <>
  486. //struct ratio_string_id<deca> : integral_constant<int,1> {};
  487. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  488. template <typename CharT>
  489. struct ratio_string<deca, CharT> :
  490. ratio_detail::ratio_string_static<deca,CharT>
  491. {};
  492. #else
  493. template <>
  494. struct ratio_string<deca, char>
  495. {
  496. static std::string short_name() {return std::string("da");}
  497. static std::string long_name() {return std::string("deca");}
  498. static std::string symbol() {return short_name();}
  499. static std::string prefix() {return long_name();}
  500. };
  501. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  502. template <>
  503. struct ratio_string<deca, char16_t>
  504. {
  505. static std::u16string short_name() {return std::u16string(u"da");}
  506. static std::u16string long_name() {return std::u16string(u"deca");}
  507. static std::u16string symbol() {return short_name();}
  508. static std::u16string prefix() {return long_name();}
  509. };
  510. template <>
  511. struct ratio_string<deca, char32_t>
  512. {
  513. static std::u32string short_name() {return std::u32string(U"da");}
  514. static std::u32string long_name() {return std::u32string(U"deca");}
  515. static std::u32string symbol() {return short_name();}
  516. static std::u32string prefix() {return long_name();}
  517. };
  518. #endif
  519. #ifndef BOOST_NO_STD_WSTRING
  520. template <>
  521. struct ratio_string<deca, wchar_t>
  522. {
  523. static std::wstring short_name() {return std::wstring(L"da");}
  524. static std::wstring long_name() {return std::wstring(L"deca");}
  525. static std::wstring symbol() {return short_name();}
  526. static std::wstring prefix() {return long_name();}
  527. };
  528. #endif
  529. #endif
  530. // hecto
  531. //template <>
  532. //struct ratio_string_is_localizable<hecto> : true_type {};
  533. //
  534. //template <>
  535. //struct ratio_string_id<hecto> : integral_constant<int,2> {};
  536. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  537. template <typename CharT>
  538. struct ratio_string<hecto, CharT> :
  539. ratio_detail::ratio_string_static<hecto,CharT>
  540. {};
  541. #else
  542. template <>
  543. struct ratio_string<hecto, char>
  544. {
  545. static std::string short_name() {return std::string(1, 'h');}
  546. static std::string long_name() {return std::string("hecto");}
  547. static std::string symbol() {return short_name();}
  548. static std::string prefix() {return long_name();}
  549. };
  550. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  551. template <>
  552. struct ratio_string<hecto, char16_t>
  553. {
  554. static std::u16string short_name() {return std::u16string(1, u'h');}
  555. static std::u16string long_name() {return std::u16string(u"hecto");}
  556. static std::u16string symbol() {return short_name();}
  557. static std::u16string prefix() {return long_name();}
  558. };
  559. template <>
  560. struct ratio_string<hecto, char32_t>
  561. {
  562. static std::u32string short_name() {return std::u32string(1, U'h');}
  563. static std::u32string long_name() {return std::u32string(U"hecto");}
  564. static std::u32string symbol() {return short_name();}
  565. static std::u32string prefix() {return long_name();}
  566. };
  567. #endif
  568. #ifndef BOOST_NO_STD_WSTRING
  569. template <>
  570. struct ratio_string<hecto, wchar_t>
  571. {
  572. static std::wstring short_name() {return std::wstring(1, L'h');}
  573. static std::wstring long_name() {return std::wstring(L"hecto");}
  574. static std::wstring symbol() {return short_name();}
  575. static std::wstring prefix() {return long_name();}
  576. };
  577. #endif
  578. #endif
  579. // kilo
  580. //template <>
  581. //struct ratio_string_is_localizable<kilo> : true_type {};
  582. //
  583. //template <>
  584. //struct ratio_string_id<kilo> : integral_constant<int,3> {};
  585. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  586. template <typename CharT>
  587. struct ratio_string<kilo, CharT> :
  588. ratio_detail::ratio_string_static<kilo,CharT>
  589. {};
  590. #else
  591. template <>
  592. struct ratio_string<kilo, char>
  593. {
  594. static std::string short_name() {return std::string(1, 'k');}
  595. static std::string long_name() {return std::string("kilo");}
  596. static std::string symbol() {return short_name();}
  597. static std::string prefix() {return long_name();}
  598. };
  599. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  600. template <>
  601. struct ratio_string<kilo, char16_t>
  602. {
  603. static std::u16string short_name() {return std::u16string(1, u'k');}
  604. static std::u16string long_name() {return std::u16string(u"kilo");}
  605. static std::u16string symbol() {return short_name();}
  606. static std::u16string prefix() {return long_name();}
  607. };
  608. template <>
  609. struct ratio_string<kilo, char32_t>
  610. {
  611. static std::u32string short_name() {return std::u32string(1, U'k');}
  612. static std::u32string long_name() {return std::u32string(U"kilo");}
  613. static std::u32string symbol() {return short_name();}
  614. static std::u32string prefix() {return long_name();}
  615. };
  616. #endif
  617. #ifndef BOOST_NO_STD_WSTRING
  618. template <>
  619. struct ratio_string<kilo, wchar_t>
  620. {
  621. static std::wstring short_name() {return std::wstring(1, L'k');}
  622. static std::wstring long_name() {return std::wstring(L"kilo");}
  623. static std::wstring symbol() {return short_name();}
  624. static std::wstring prefix() {return long_name();}
  625. };
  626. #endif
  627. #endif
  628. // mega
  629. //template <>
  630. //struct ratio_string_is_localizable<mega> : true_type {};
  631. //
  632. //template <>
  633. //struct ratio_string_id<mega> : integral_constant<int,6> {};
  634. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  635. template <typename CharT>
  636. struct ratio_string<mega, CharT> :
  637. ratio_detail::ratio_string_static<mega,CharT>
  638. {};
  639. #else
  640. template <>
  641. struct ratio_string<mega, char>
  642. {
  643. static std::string short_name() {return std::string(1, 'M');}
  644. static std::string long_name() {return std::string("mega");}
  645. static std::string symbol() {return short_name();}
  646. static std::string prefix() {return long_name();}
  647. };
  648. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  649. template <>
  650. struct ratio_string<mega, char16_t>
  651. {
  652. static std::u16string short_name() {return std::u16string(1, u'M');}
  653. static std::u16string long_name() {return std::u16string(u"mega");}
  654. static std::u16string symbol() {return short_name();}
  655. static std::u16string prefix() {return long_name();}
  656. };
  657. template <>
  658. struct ratio_string<mega, char32_t>
  659. {
  660. static std::u32string short_name() {return std::u32string(1, U'M');}
  661. static std::u32string long_name() {return std::u32string(U"mega");}
  662. static std::u32string symbol() {return short_name();}
  663. static std::u32string prefix() {return long_name();}
  664. };
  665. #endif
  666. #ifndef BOOST_NO_STD_WSTRING
  667. template <>
  668. struct ratio_string<mega, wchar_t>
  669. {
  670. static std::wstring short_name() {return std::wstring(1, L'M');}
  671. static std::wstring long_name() {return std::wstring(L"mega");}
  672. static std::wstring symbol() {return short_name();}
  673. static std::wstring prefix() {return long_name();}
  674. };
  675. #endif
  676. #endif
  677. // giga
  678. //template <>
  679. //struct ratio_string_is_localizable<giga> : true_type {};
  680. //
  681. //template <>
  682. //struct ratio_string_id<giga> : integral_constant<int,9> {};
  683. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  684. template <typename CharT>
  685. struct ratio_string<giga, CharT> :
  686. ratio_detail::ratio_string_static<giga,CharT>
  687. {};
  688. #else
  689. template <>
  690. struct ratio_string<giga, char>
  691. {
  692. static std::string short_name() {return std::string(1, 'G');}
  693. static std::string long_name() {return std::string("giga");}
  694. static std::string symbol() {return short_name();}
  695. static std::string prefix() {return long_name();}
  696. };
  697. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  698. template <>
  699. struct ratio_string<giga, char16_t>
  700. {
  701. static std::u16string short_name() {return std::u16string(1, u'G');}
  702. static std::u16string long_name() {return std::u16string(u"giga");}
  703. static std::u16string symbol() {return short_name();}
  704. static std::u16string prefix() {return long_name();}
  705. };
  706. template <>
  707. struct ratio_string<giga, char32_t>
  708. {
  709. static std::u32string short_name() {return std::u32string(1, U'G');}
  710. static std::u32string long_name() {return std::u32string(U"giga");}
  711. static std::u32string symbol() {return short_name();}
  712. static std::u32string prefix() {return long_name();}
  713. };
  714. #endif
  715. #ifndef BOOST_NO_STD_WSTRING
  716. template <>
  717. struct ratio_string<giga, wchar_t>
  718. {
  719. static std::wstring short_name() {return std::wstring(1, L'G');}
  720. static std::wstring long_name() {return std::wstring(L"giga");}
  721. static std::wstring symbol() {return short_name();}
  722. static std::wstring prefix() {return long_name();}
  723. };
  724. #endif
  725. #endif
  726. // tera
  727. //template <>
  728. //struct ratio_string_is_localizable<tera> : true_type {};
  729. //
  730. //template <>
  731. //struct ratio_string_id<tera> : integral_constant<int,12> {};
  732. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  733. template <typename CharT>
  734. struct ratio_string<tera, CharT> :
  735. ratio_detail::ratio_string_static<tera,CharT>
  736. {};
  737. #else
  738. template <>
  739. struct ratio_string<tera, char>
  740. {
  741. static std::string short_name() {return std::string(1, 'T');}
  742. static std::string long_name() {return std::string("tera");}
  743. static std::string symbol() {return short_name();}
  744. static std::string prefix() {return long_name();}
  745. };
  746. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  747. template <>
  748. struct ratio_string<tera, char16_t>
  749. {
  750. static std::u16string short_name() {return std::u16string(1, u'T');}
  751. static std::u16string long_name() {return std::u16string(u"tera");}
  752. static std::u16string symbol() {return short_name();}
  753. static std::u16string prefix() {return long_name();}
  754. };
  755. template <>
  756. struct ratio_string<tera, char32_t>
  757. {
  758. static std::u32string short_name() {return std::u32string(1, U'T');}
  759. static std::u32string long_name() {return std::u32string(U"tera");}
  760. static std::u32string symbol() {return short_name();}
  761. static std::u32string prefix() {return long_name();}
  762. };
  763. #endif
  764. #ifndef BOOST_NO_STD_WSTRING
  765. template <>
  766. struct ratio_string<tera, wchar_t>
  767. {
  768. static std::wstring short_name() {return std::wstring(1, L'T');}
  769. static std::wstring long_name() {return std::wstring(L"tera");}
  770. static std::wstring symbol() {return short_name();}
  771. static std::wstring prefix() {return long_name();}
  772. };
  773. #endif
  774. #endif
  775. // peta
  776. //template <>
  777. //struct ratio_string_is_localizable<peta> : true_type {};
  778. //
  779. //template <>
  780. //struct ratio_string_id<peta> : integral_constant<int,15> {};
  781. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  782. template <typename CharT>
  783. struct ratio_string<peta, CharT> :
  784. ratio_detail::ratio_string_static<peta,CharT>
  785. {};
  786. #else
  787. template <>
  788. struct ratio_string<peta, char>
  789. {
  790. static std::string short_name() {return std::string(1, 'P');}
  791. static std::string long_name() {return std::string("peta");}
  792. static std::string symbol() {return short_name();}
  793. static std::string prefix() {return long_name();}
  794. };
  795. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  796. template <>
  797. struct ratio_string<peta, char16_t>
  798. {
  799. static std::u16string short_name() {return std::u16string(1, u'P');}
  800. static std::u16string long_name() {return std::u16string(u"peta");}
  801. static std::u16string symbol() {return short_name();}
  802. static std::u16string prefix() {return long_name();}
  803. };
  804. template <>
  805. struct ratio_string<peta, char32_t>
  806. {
  807. static std::u32string short_name() {return std::u32string(1, U'P');}
  808. static std::u32string long_name() {return std::u32string(U"peta");}
  809. static std::u32string symbol() {return short_name();}
  810. static std::u32string prefix() {return long_name();}
  811. };
  812. #endif
  813. #ifndef BOOST_NO_STD_WSTRING
  814. template <>
  815. struct ratio_string<peta, wchar_t>
  816. {
  817. static std::wstring short_name() {return std::wstring(1, L'P');}
  818. static std::wstring long_name() {return std::wstring(L"peta");}
  819. static std::wstring symbol() {return short_name();}
  820. static std::wstring prefix() {return long_name();}
  821. };
  822. #endif
  823. #endif
  824. // exa
  825. //template <>
  826. //struct ratio_string_is_localizable<exa> : true_type {};
  827. //
  828. //template <>
  829. //struct ratio_string_id<exa> : integral_constant<int,18> {};
  830. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  831. template <typename CharT>
  832. struct ratio_string<exa, CharT> :
  833. ratio_detail::ratio_string_static<exa,CharT>
  834. {};
  835. #else
  836. template <>
  837. struct ratio_string<exa, char>
  838. {
  839. static std::string short_name() {return std::string(1, 'E');}
  840. static std::string long_name() {return std::string("exa");}
  841. static std::string symbol() {return short_name();}
  842. static std::string prefix() {return long_name();}
  843. };
  844. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  845. template <>
  846. struct ratio_string<exa, char16_t>
  847. {
  848. static std::u16string short_name() {return std::u16string(1, u'E');}
  849. static std::u16string long_name() {return std::u16string(u"exa");}
  850. static std::u16string symbol() {return short_name();}
  851. static std::u16string prefix() {return long_name();}
  852. };
  853. template <>
  854. struct ratio_string<exa, char32_t>
  855. {
  856. static std::u32string short_name() {return std::u32string(1, U'E');}
  857. static std::u32string long_name() {return std::u32string(U"exa");}
  858. static std::u32string symbol() {return short_name();}
  859. static std::u32string prefix() {return long_name();}
  860. };
  861. #endif
  862. #ifndef BOOST_NO_STD_WSTRING
  863. template <>
  864. struct ratio_string<exa, wchar_t>
  865. {
  866. static std::wstring short_name() {return std::wstring(1, L'E');}
  867. static std::wstring long_name() {return std::wstring(L"exa");}
  868. static std::wstring symbol() {return short_name();}
  869. static std::wstring prefix() {return long_name();}
  870. };
  871. #endif
  872. #endif
  873. #ifdef BOOST_RATIO_EXTENSIONS
  874. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  875. template <typename CharT>
  876. struct ratio_string<kibi, CharT> :
  877. ratio_detail::ratio_string_static<kibi,CharT>
  878. {};
  879. #else
  880. template <>
  881. struct ratio_string<kibi, char>
  882. {
  883. static std::string short_name() {return std::string("Ki");}
  884. static std::string long_name() {return std::string("kibi");}
  885. static std::string symbol() {return short_name();}
  886. static std::string prefix() {return long_name();}
  887. };
  888. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  889. template <>
  890. struct ratio_string<kibi, char16_t>
  891. {
  892. static std::u16string short_name() {return std::u16string(u"Ki");}
  893. static std::u16string long_name() {return std::u16string(u"kibi");}
  894. static std::u16string symbol() {return short_name();}
  895. static std::u16string prefix() {return long_name();}
  896. };
  897. template <>
  898. struct ratio_string<kibi, char32_t>
  899. {
  900. static std::u32string short_name() {return std::u32string(U"Ki");}
  901. static std::u32string long_name() {return std::u32string(U"kibi");}
  902. static std::u32string symbol() {return short_name();}
  903. static std::u32string prefix() {return long_name();}
  904. };
  905. #endif
  906. #ifndef BOOST_NO_STD_WSTRING
  907. template <>
  908. struct ratio_string<kibi, wchar_t>
  909. {
  910. static std::wstring short_name() {return std::wstring(L"Ki");}
  911. static std::wstring long_name() {return std::wstring(L"kibi");}
  912. static std::wstring symbol() {return short_name();}
  913. static std::wstring prefix() {return long_name();}
  914. };
  915. #endif
  916. #endif
  917. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  918. template <typename CharT>
  919. struct ratio_string<mebi, CharT> :
  920. ratio_detail::ratio_string_static<mebi,CharT>
  921. {};
  922. #else
  923. template <>
  924. struct ratio_string<mebi, char>
  925. {
  926. static std::string short_name() {return std::string("Mi");}
  927. static std::string long_name() {return std::string("mebi");}
  928. static std::string symbol() {return short_name();}
  929. static std::string prefix() {return long_name();}
  930. };
  931. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  932. template <>
  933. struct ratio_string<mebi, char16_t>
  934. {
  935. static std::u16string short_name() {return std::u16string(u"Mi");}
  936. static std::u16string long_name() {return std::u16string(u"mebi");}
  937. static std::u16string symbol() {return short_name();}
  938. static std::u16string prefix() {return long_name();}
  939. };
  940. template <>
  941. struct ratio_string<mebi, char32_t>
  942. {
  943. static std::u32string short_name() {return std::u32string(U"Mi");}
  944. static std::u32string long_name() {return std::u32string(U"mebi");}
  945. static std::u32string symbol() {return short_name();}
  946. static std::u32string prefix() {return long_name();}
  947. };
  948. #endif
  949. #ifndef BOOST_NO_STD_WSTRING
  950. template <>
  951. struct ratio_string<mebi, wchar_t>
  952. {
  953. static std::wstring short_name() {return std::wstring(L"Mi");}
  954. static std::wstring long_name() {return std::wstring(L"mebi");}
  955. static std::wstring symbol() {return short_name();}
  956. static std::wstring prefix() {return long_name();}
  957. };
  958. #endif
  959. #endif
  960. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  961. template <typename CharT>
  962. struct ratio_string<gibi, CharT> :
  963. ratio_detail::ratio_string_static<gibi,CharT>
  964. {};
  965. #else
  966. template <>
  967. struct ratio_string<gibi, char>
  968. {
  969. static std::string short_name() {return std::string("Gi");}
  970. static std::string long_name() {return std::string("gibi");}
  971. static std::string symbol() {return short_name();}
  972. static std::string prefix() {return long_name();}
  973. };
  974. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  975. template <>
  976. struct ratio_string<gibi, char16_t>
  977. {
  978. static std::u16string short_name() {return std::u16string(u"Gi");}
  979. static std::u16string long_name() {return std::u16string(u"gibi");}
  980. static std::u16string symbol() {return short_name();}
  981. static std::u16string prefix() {return long_name();}
  982. };
  983. template <>
  984. struct ratio_string<gibi, char32_t>
  985. {
  986. static std::u32string short_name() {return std::u32string(U"Gi");}
  987. static std::u32string long_name() {return std::u32string(U"gibi");}
  988. static std::u32string symbol() {return short_name();}
  989. static std::u32string prefix() {return long_name();}
  990. };
  991. #endif
  992. #ifndef BOOST_NO_STD_WSTRING
  993. template <>
  994. struct ratio_string<gibi, wchar_t>
  995. {
  996. static std::wstring short_name() {return std::wstring(L"Gi");}
  997. static std::wstring long_name() {return std::wstring(L"gibi");}
  998. static std::wstring symbol() {return short_name();}
  999. static std::wstring prefix() {return long_name();}
  1000. };
  1001. #endif
  1002. #endif
  1003. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  1004. template <typename CharT>
  1005. struct ratio_string<tebi, CharT> :
  1006. ratio_detail::ratio_string_static<tebi,CharT>
  1007. {};
  1008. #else
  1009. template <>
  1010. struct ratio_string<tebi, char>
  1011. {
  1012. static std::string short_name() {return std::string("Ti");}
  1013. static std::string long_name() {return std::string("tebi");}
  1014. static std::string symbol() {return short_name();}
  1015. static std::string prefix() {return long_name();}
  1016. };
  1017. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  1018. template <>
  1019. struct ratio_string<tebi, char16_t>
  1020. {
  1021. static std::u16string short_name() {return std::u16string(u"Ti");}
  1022. static std::u16string long_name() {return std::u16string(u"tebi");}
  1023. static std::u16string symbol() {return short_name();}
  1024. static std::u16string prefix() {return long_name();}
  1025. };
  1026. template <>
  1027. struct ratio_string<tebi, char32_t>
  1028. {
  1029. static std::u32string short_name() {return std::u32string(U"Ti");}
  1030. static std::u32string long_name() {return std::u32string(U"tebi");}
  1031. static std::u32string symbol() {return short_name();}
  1032. static std::u32string prefix() {return long_name();}
  1033. };
  1034. #endif
  1035. #ifndef BOOST_NO_STD_WSTRING
  1036. template <>
  1037. struct ratio_string<tebi, wchar_t>
  1038. {
  1039. static std::wstring short_name() {return std::wstring(L"Ti");}
  1040. static std::wstring long_name() {return std::wstring(L"tebi");}
  1041. static std::wstring symbol() {return short_name();}
  1042. static std::wstring prefix() {return long_name();}
  1043. };
  1044. #endif
  1045. #endif
  1046. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  1047. template <typename CharT>
  1048. struct ratio_string<pebi, CharT> :
  1049. ratio_detail::ratio_string_static<pebi,CharT>
  1050. {};
  1051. #else
  1052. template <>
  1053. struct ratio_string<pebi, char>
  1054. {
  1055. static std::string short_name() {return std::string("Pi");}
  1056. static std::string long_name() {return std::string("pebi");}
  1057. static std::string symbol() {return short_name();}
  1058. static std::string prefix() {return long_name();}
  1059. };
  1060. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  1061. template <>
  1062. struct ratio_string<pebi, char16_t>
  1063. {
  1064. static std::u16string short_name() {return std::u16string(u"Pi");}
  1065. static std::u16string long_name() {return std::u16string(u"pebi");}
  1066. static std::u16string symbol() {return short_name();}
  1067. static std::u16string prefix() {return long_name();}
  1068. };
  1069. template <>
  1070. struct ratio_string<pebi, char32_t>
  1071. {
  1072. static std::u32string short_name() {return std::u32string(U"Pi");}
  1073. static std::u32string long_name() {return std::u32string(U"pebi");}
  1074. static std::u32string symbol() {return short_name();}
  1075. static std::u32string prefix() {return long_name();}
  1076. };
  1077. #endif
  1078. #ifndef BOOST_NO_STD_WSTRING
  1079. template <>
  1080. struct ratio_string<pebi, wchar_t>
  1081. {
  1082. static std::wstring short_name() {return std::wstring(L"Pi");}
  1083. static std::wstring long_name() {return std::wstring(L"pebi");}
  1084. static std::wstring symbol() {return short_name();}
  1085. static std::wstring prefix() {return long_name();}
  1086. };
  1087. #endif
  1088. #endif
  1089. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  1090. template <typename CharT>
  1091. struct ratio_string<exbi, CharT> :
  1092. ratio_detail::ratio_string_static<exbi,CharT>
  1093. {};
  1094. #else
  1095. template <>
  1096. struct ratio_string<exbi, char>
  1097. {
  1098. static std::string short_name() {return std::string("Ei");}
  1099. static std::string long_name() {return std::string("exbi");}
  1100. static std::string symbol() {return short_name();}
  1101. static std::string prefix() {return long_name();}
  1102. };
  1103. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  1104. template <>
  1105. struct ratio_string<exbi, char16_t>
  1106. {
  1107. static std::u16string short_name() {return std::u16string(u"Ei");}
  1108. static std::u16string long_name() {return std::u16string(u"exbi");}
  1109. static std::u16string symbol() {return short_name();}
  1110. static std::u16string prefix() {return long_name();}
  1111. };
  1112. template <>
  1113. struct ratio_string<exbi, char32_t>
  1114. {
  1115. static std::u32string short_name() {return std::u32string(U"Ei");}
  1116. static std::u32string long_name() {return std::u32string(U"exbi");}
  1117. static std::u32string symbol() {return short_name();}
  1118. static std::u32string prefix() {return long_name();}
  1119. };
  1120. #endif
  1121. #ifndef BOOST_NO_STD_WSTRING
  1122. template <>
  1123. struct ratio_string<exbi, wchar_t>
  1124. {
  1125. static std::wstring short_name() {return std::wstring(L"Ei");}
  1126. static std::wstring long_name() {return std::wstring(L"exbi");}
  1127. static std::wstring symbol() {return short_name();}
  1128. static std::wstring prefix() {return long_name();}
  1129. };
  1130. #endif
  1131. #endif
  1132. #endif
  1133. }
  1134. #endif // BOOST_RATIO_RATIO_IO_HPP