ratio_io.hpp 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076
  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_RATIO_IO_HPP
  12. #define BOOST_RATIO_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> prefix();
  23. static basic_string<CharT> symbol();
  24. };
  25. } // boost
  26. */
  27. #include <boost/ratio/config.hpp>
  28. #ifdef BOOST_RATIO_PROVIDES_DEPRECATED_FEATURES_SINCE_V2_0_0
  29. #include <boost/ratio/detail/ratio_io.hpp>
  30. #else
  31. #include <boost/config.hpp>
  32. #include <boost/ratio/ratio.hpp>
  33. #include <boost/type_traits/integral_constant.hpp>
  34. #include <string>
  35. #include <sstream>
  36. #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)
  37. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  38. #undef BOOST_RATIO_HAS_UNICODE_SUPPORT
  39. #endif
  40. #else
  41. #define BOOST_RATIO_HAS_UNICODE_SUPPORT 1
  42. #endif
  43. namespace boost {
  44. //template <class Ratio>
  45. //struct ratio_string_is_localizable : false_type {};
  46. //template <class Ratio>
  47. //struct ratio_string_id : integral_constant<int,0> {};
  48. template <class Ratio, class CharT>
  49. struct ratio_string
  50. {
  51. static std::basic_string<CharT> symbol() {return prefix();}
  52. static std::basic_string<CharT> prefix();
  53. };
  54. template <class Ratio, class CharT>
  55. std::basic_string<CharT>
  56. ratio_string<Ratio, CharT>::prefix()
  57. {
  58. std::basic_ostringstream<CharT> os;
  59. os << CharT('[') << Ratio::num << CharT('/')
  60. << Ratio::den << CharT(']');
  61. return os.str();
  62. }
  63. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  64. namespace ratio_detail {
  65. template <class Ratio, class CharT>
  66. struct ratio_string_static
  67. {
  68. static std::string symbol() {
  69. return std::basic_string<CharT>(
  70. static_string::c_str<
  71. typename ratio_static_string<Ratio, CharT>::symbol
  72. >::value);
  73. }
  74. static std::string prefix() {
  75. return std::basic_string<CharT>(
  76. static_string::c_str<
  77. typename ratio_static_string<Ratio, CharT>::prefix
  78. >::value);
  79. }
  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 symbol() {return std::string(1, 'a');}
  99. static std::string prefix() {return std::string("atto");}
  100. };
  101. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  102. template <>
  103. struct ratio_string<atto, char16_t>
  104. {
  105. static std::u16string symbol() {return std::u16string(1, u'a');}
  106. static std::u16string prefix() {return std::u16string(u"atto");}
  107. };
  108. template <>
  109. struct ratio_string<atto, char32_t>
  110. {
  111. static std::u32string symbol() {return std::u32string(1, U'a');}
  112. static std::u32string prefix() {return std::u32string(U"atto");}
  113. };
  114. #endif
  115. #ifndef BOOST_NO_STD_WSTRING
  116. template <>
  117. struct ratio_string<atto, wchar_t>
  118. {
  119. static std::wstring symbol() {return std::wstring(1, L'a');}
  120. static std::wstring prefix() {return std::wstring(L"atto");}
  121. };
  122. #endif
  123. #endif
  124. // femto
  125. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  126. template <typename CharT>
  127. struct ratio_string<femto, CharT> :
  128. ratio_detail::ratio_string_static<femto,CharT>
  129. {};
  130. #else
  131. template <>
  132. struct ratio_string<femto, char>
  133. {
  134. static std::string symbol() {return std::string(1, 'f');}
  135. static std::string prefix() {return std::string("femto");}
  136. };
  137. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  138. template <>
  139. struct ratio_string<femto, char16_t>
  140. {
  141. static std::u16string symbol() {return std::u16string(1, u'f');}
  142. static std::u16string prefix() {return std::u16string(u"femto");}
  143. };
  144. template <>
  145. struct ratio_string<femto, char32_t>
  146. {
  147. static std::u32string symbol() {return std::u32string(1, U'f');}
  148. static std::u32string prefix() {return std::u32string(U"femto");}
  149. };
  150. #endif
  151. #ifndef BOOST_NO_STD_WSTRING
  152. template <>
  153. struct ratio_string<femto, wchar_t>
  154. {
  155. static std::wstring symbol() {return std::wstring(1, L'f');}
  156. static std::wstring prefix() {return std::wstring(L"femto");}
  157. };
  158. #endif
  159. #endif
  160. // pico
  161. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  162. template <typename CharT>
  163. struct ratio_string<pico, CharT> :
  164. ratio_detail::ratio_string_static<pico,CharT>
  165. {};
  166. #else
  167. template <>
  168. struct ratio_string<pico, char>
  169. {
  170. static std::string symbol() {return std::string(1, 'p');}
  171. static std::string prefix() {return std::string("pico");}
  172. };
  173. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  174. template <>
  175. struct ratio_string<pico, char16_t>
  176. {
  177. static std::u16string symbol() {return std::u16string(1, u'p');}
  178. static std::u16string prefix() {return std::u16string(u"pico");}
  179. };
  180. template <>
  181. struct ratio_string<pico, char32_t>
  182. {
  183. static std::u32string symbol() {return std::u32string(1, U'p');}
  184. static std::u32string prefix() {return std::u32string(U"pico");}
  185. };
  186. #endif
  187. #ifndef BOOST_NO_STD_WSTRING
  188. template <>
  189. struct ratio_string<pico, wchar_t>
  190. {
  191. static std::wstring symbol() {return std::wstring(1, L'p');}
  192. static std::wstring prefix() {return std::wstring(L"pico");}
  193. };
  194. #endif
  195. #endif
  196. // nano
  197. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  198. template <typename CharT>
  199. struct ratio_string<nano, CharT> :
  200. ratio_detail::ratio_string_static<nano,CharT>
  201. {};
  202. #else
  203. template <>
  204. struct ratio_string<nano, char>
  205. {
  206. static std::string symbol() {return std::string(1, 'n');}
  207. static std::string prefix() {return std::string("nano");}
  208. };
  209. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  210. template <>
  211. struct ratio_string<nano, char16_t>
  212. {
  213. static std::u16string symbol() {return std::u16string(1, u'n');}
  214. static std::u16string prefix() {return std::u16string(u"nano");}
  215. };
  216. template <>
  217. struct ratio_string<nano, char32_t>
  218. {
  219. static std::u32string symbol() {return std::u32string(1, U'n');}
  220. static std::u32string prefix() {return std::u32string(U"nano");}
  221. };
  222. #endif
  223. #ifndef BOOST_NO_STD_WSTRING
  224. template <>
  225. struct ratio_string<nano, wchar_t>
  226. {
  227. static std::wstring symbol() {return std::wstring(1, L'n');}
  228. static std::wstring prefix() {return std::wstring(L"nano");}
  229. };
  230. #endif
  231. #endif
  232. // micro
  233. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  234. template <typename CharT>
  235. struct ratio_string<micro, CharT> :
  236. ratio_detail::ratio_string_static<micro,CharT>
  237. {};
  238. #else
  239. template <>
  240. struct ratio_string<micro, char>
  241. {
  242. static std::string symbol() {return std::string("\xC2\xB5");}
  243. static std::string prefix() {return std::string("micro");}
  244. };
  245. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  246. template <>
  247. struct ratio_string<micro, char16_t>
  248. {
  249. static std::u16string symbol() {return std::u16string(1, u'\xB5');}
  250. static std::u16string prefix() {return std::u16string(u"micro");}
  251. };
  252. template <>
  253. struct ratio_string<micro, char32_t>
  254. {
  255. static std::u32string symbol() {return std::u32string(1, U'\xB5');}
  256. static std::u32string prefix() {return std::u32string(U"micro");}
  257. };
  258. #endif
  259. #ifndef BOOST_NO_STD_WSTRING
  260. template <>
  261. struct ratio_string<micro, wchar_t>
  262. {
  263. static std::wstring symbol() {return std::wstring(1, L'\xB5');}
  264. static std::wstring prefix() {return std::wstring(L"micro");}
  265. };
  266. #endif
  267. #endif
  268. // milli
  269. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  270. template <typename CharT>
  271. struct ratio_string<milli, CharT> :
  272. ratio_detail::ratio_string_static<milli,CharT>
  273. {};
  274. #else
  275. template <>
  276. struct ratio_string<milli, char>
  277. {
  278. static std::string symbol() {return std::string(1, 'm');}
  279. static std::string prefix() {return std::string("milli");}
  280. };
  281. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  282. template <>
  283. struct ratio_string<milli, char16_t>
  284. {
  285. static std::u16string symbol() {return std::u16string(1, u'm');}
  286. static std::u16string prefix() {return std::u16string(u"milli");}
  287. };
  288. template <>
  289. struct ratio_string<milli, char32_t>
  290. {
  291. static std::u32string symbol() {return std::u32string(1, U'm');}
  292. static std::u32string prefix() {return std::u32string(U"milli");}
  293. };
  294. #endif
  295. #ifndef BOOST_NO_STD_WSTRING
  296. template <>
  297. struct ratio_string<milli, wchar_t>
  298. {
  299. static std::wstring symbol() {return std::wstring(1, L'm');}
  300. static std::wstring prefix() {return std::wstring(L"milli");}
  301. };
  302. #endif
  303. #endif
  304. // centi
  305. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  306. template <typename CharT>
  307. struct ratio_string<centi, CharT> :
  308. ratio_detail::ratio_string_static<centi,CharT>
  309. {};
  310. #else
  311. template <>
  312. struct ratio_string<centi, char>
  313. {
  314. static std::string symbol() {return std::string(1, 'c');}
  315. static std::string prefix() {return std::string("centi");}
  316. };
  317. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  318. template <>
  319. struct ratio_string<centi, char16_t>
  320. {
  321. static std::u16string symbol() {return std::u16string(1, u'c');}
  322. static std::u16string prefix() {return std::u16string(u"centi");}
  323. };
  324. template <>
  325. struct ratio_string<centi, char32_t>
  326. {
  327. static std::u32string symbol() {return std::u32string(1, U'c');}
  328. static std::u32string prefix() {return std::u32string(U"centi");}
  329. };
  330. #endif
  331. #ifndef BOOST_NO_STD_WSTRING
  332. template <>
  333. struct ratio_string<centi, wchar_t>
  334. {
  335. static std::wstring symbol() {return std::wstring(1, L'c');}
  336. static std::wstring prefix() {return std::wstring(L"centi");}
  337. };
  338. #endif
  339. #endif
  340. // deci
  341. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  342. template <typename CharT>
  343. struct ratio_string<deci, CharT> :
  344. ratio_detail::ratio_string_static<deci,CharT>
  345. {};
  346. #else
  347. template <>
  348. struct ratio_string<deci, char>
  349. {
  350. static std::string symbol() {return std::string(1, 'd');}
  351. static std::string prefix() {return std::string("deci");}
  352. };
  353. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  354. template <>
  355. struct ratio_string<deci, char16_t>
  356. {
  357. static std::u16string symbol() {return std::u16string(1, u'd');}
  358. static std::u16string prefix() {return std::u16string(u"deci");}
  359. };
  360. template <>
  361. struct ratio_string<deci, char32_t>
  362. {
  363. static std::u32string symbol() {return std::u32string(1, U'd');}
  364. static std::u32string prefix() {return std::u32string(U"deci");}
  365. };
  366. #endif
  367. #ifndef BOOST_NO_STD_WSTRING
  368. template <>
  369. struct ratio_string<deci, wchar_t>
  370. {
  371. static std::wstring symbol() {return std::wstring(1, L'd');}
  372. static std::wstring prefix() {return std::wstring(L"deci");}
  373. };
  374. #endif
  375. #endif
  376. // unit
  377. // deca
  378. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  379. template <typename CharT>
  380. struct ratio_string<deca, CharT> :
  381. ratio_detail::ratio_string_static<deca,CharT>
  382. {};
  383. #else
  384. template <>
  385. struct ratio_string<deca, char>
  386. {
  387. static std::string symbol() {return std::string("da");}
  388. static std::string prefix() {return std::string("deca");}
  389. };
  390. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  391. template <>
  392. struct ratio_string<deca, char16_t>
  393. {
  394. static std::u16string symbol() {return std::u16string(u"da");}
  395. static std::u16string prefix() {return std::u16string(u"deca");}
  396. };
  397. template <>
  398. struct ratio_string<deca, char32_t>
  399. {
  400. static std::u32string symbol() {return std::u32string(U"da");}
  401. static std::u32string prefix() {return std::u32string(U"deca");}
  402. };
  403. #endif
  404. #ifndef BOOST_NO_STD_WSTRING
  405. template <>
  406. struct ratio_string<deca, wchar_t>
  407. {
  408. static std::wstring symbol() {return std::wstring(L"da");}
  409. static std::wstring prefix() {return std::wstring(L"deca");}
  410. };
  411. #endif
  412. #endif
  413. // hecto
  414. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  415. template <typename CharT>
  416. struct ratio_string<hecto, CharT> :
  417. ratio_detail::ratio_string_static<hecto,CharT>
  418. {};
  419. #else
  420. template <>
  421. struct ratio_string<hecto, char>
  422. {
  423. static std::string symbol() {return std::string(1, 'h');}
  424. static std::string prefix() {return std::string("hecto");}
  425. };
  426. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  427. template <>
  428. struct ratio_string<hecto, char16_t>
  429. {
  430. static std::u16string symbol() {return std::u16string(1, u'h');}
  431. static std::u16string prefix() {return std::u16string(u"hecto");}
  432. };
  433. template <>
  434. struct ratio_string<hecto, char32_t>
  435. {
  436. static std::u32string symbol() {return std::u32string(1, U'h');}
  437. static std::u32string prefix() {return std::u32string(U"hecto");}
  438. };
  439. #endif
  440. #ifndef BOOST_NO_STD_WSTRING
  441. template <>
  442. struct ratio_string<hecto, wchar_t>
  443. {
  444. static std::wstring symbol() {return std::wstring(1, L'h');}
  445. static std::wstring prefix() {return std::wstring(L"hecto");}
  446. };
  447. #endif
  448. #endif
  449. // kilo
  450. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  451. template <typename CharT>
  452. struct ratio_string<kilo, CharT> :
  453. ratio_detail::ratio_string_static<kilo,CharT>
  454. {};
  455. #else
  456. template <>
  457. struct ratio_string<kilo, char>
  458. {
  459. static std::string symbol() {return std::string(1, 'k');}
  460. static std::string prefix() {return std::string("kilo");}
  461. };
  462. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  463. template <>
  464. struct ratio_string<kilo, char16_t>
  465. {
  466. static std::u16string symbol() {return std::u16string(1, u'k');}
  467. static std::u16string prefix() {return std::u16string(u"kilo");}
  468. };
  469. template <>
  470. struct ratio_string<kilo, char32_t>
  471. {
  472. static std::u32string symbol() {return std::u32string(1, U'k');}
  473. static std::u32string prefix() {return std::u32string(U"kilo");}
  474. };
  475. #endif
  476. #ifndef BOOST_NO_STD_WSTRING
  477. template <>
  478. struct ratio_string<kilo, wchar_t>
  479. {
  480. static std::wstring symbol() {return std::wstring(1, L'k');}
  481. static std::wstring prefix() {return std::wstring(L"kilo");}
  482. };
  483. #endif
  484. #endif
  485. // mega
  486. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  487. template <typename CharT>
  488. struct ratio_string<mega, CharT> :
  489. ratio_detail::ratio_string_static<mega,CharT>
  490. {};
  491. #else
  492. template <>
  493. struct ratio_string<mega, char>
  494. {
  495. static std::string symbol() {return std::string(1, 'M');}
  496. static std::string prefix() {return std::string("mega");}
  497. };
  498. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  499. template <>
  500. struct ratio_string<mega, char16_t>
  501. {
  502. static std::u16string symbol() {return std::u16string(1, u'M');}
  503. static std::u16string prefix() {return std::u16string(u"mega");}
  504. };
  505. template <>
  506. struct ratio_string<mega, char32_t>
  507. {
  508. static std::u32string symbol() {return std::u32string(1, U'M');}
  509. static std::u32string prefix() {return std::u32string(U"mega");}
  510. };
  511. #endif
  512. #ifndef BOOST_NO_STD_WSTRING
  513. template <>
  514. struct ratio_string<mega, wchar_t>
  515. {
  516. static std::wstring symbol() {return std::wstring(1, L'M');}
  517. static std::wstring prefix() {return std::wstring(L"mega");}
  518. };
  519. #endif
  520. #endif
  521. // giga
  522. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  523. template <typename CharT>
  524. struct ratio_string<giga, CharT> :
  525. ratio_detail::ratio_string_static<giga,CharT>
  526. {};
  527. #else
  528. template <>
  529. struct ratio_string<giga, char>
  530. {
  531. static std::string symbol() {return std::string(1, 'G');}
  532. static std::string prefix() {return std::string("giga");}
  533. };
  534. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  535. template <>
  536. struct ratio_string<giga, char16_t>
  537. {
  538. static std::u16string symbol() {return std::u16string(1, u'G');}
  539. static std::u16string prefix() {return std::u16string(u"giga");}
  540. };
  541. template <>
  542. struct ratio_string<giga, char32_t>
  543. {
  544. static std::u32string symbol() {return std::u32string(1, U'G');}
  545. static std::u32string prefix() {return std::u32string(U"giga");}
  546. };
  547. #endif
  548. #ifndef BOOST_NO_STD_WSTRING
  549. template <>
  550. struct ratio_string<giga, wchar_t>
  551. {
  552. static std::wstring symbol() {return std::wstring(1, L'G');}
  553. static std::wstring prefix() {return std::wstring(L"giga");}
  554. };
  555. #endif
  556. #endif
  557. // tera
  558. //template <>
  559. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  560. template <typename CharT>
  561. struct ratio_string<tera, CharT> :
  562. ratio_detail::ratio_string_static<tera,CharT>
  563. {};
  564. #else
  565. template <>
  566. struct ratio_string<tera, char>
  567. {
  568. static std::string symbol() {return std::string(1, 'T');}
  569. static std::string prefix() {return std::string("tera");}
  570. };
  571. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  572. template <>
  573. struct ratio_string<tera, char16_t>
  574. {
  575. static std::u16string symbol() {return std::u16string(1, u'T');}
  576. static std::u16string prefix() {return std::u16string(u"tera");}
  577. };
  578. template <>
  579. struct ratio_string<tera, char32_t>
  580. {
  581. static std::u32string symbol() {return std::u32string(1, U'T');}
  582. static std::u32string prefix() {return std::u32string(U"tera");}
  583. };
  584. #endif
  585. #ifndef BOOST_NO_STD_WSTRING
  586. template <>
  587. struct ratio_string<tera, wchar_t>
  588. {
  589. static std::wstring symbol() {return std::wstring(1, L'T');}
  590. static std::wstring prefix() {return std::wstring(L"tera");}
  591. };
  592. #endif
  593. #endif
  594. // peta
  595. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  596. template <typename CharT>
  597. struct ratio_string<peta, CharT> :
  598. ratio_detail::ratio_string_static<peta,CharT>
  599. {};
  600. #else
  601. template <>
  602. struct ratio_string<peta, char>
  603. {
  604. static std::string symbol() {return std::string(1, 'P');}
  605. static std::string prefix() {return std::string("peta");}
  606. };
  607. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  608. template <>
  609. struct ratio_string<peta, char16_t>
  610. {
  611. static std::u16string symbol() {return std::u16string(1, u'P');}
  612. static std::u16string prefix() {return std::u16string(u"peta");}
  613. };
  614. template <>
  615. struct ratio_string<peta, char32_t>
  616. {
  617. static std::u32string symbol() {return std::u32string(1, U'P');}
  618. static std::u32string prefix() {return std::u32string(U"peta");}
  619. };
  620. #endif
  621. #ifndef BOOST_NO_STD_WSTRING
  622. template <>
  623. struct ratio_string<peta, wchar_t>
  624. {
  625. static std::wstring symbol() {return std::wstring(1, L'P');}
  626. static std::wstring prefix() {return std::wstring(L"peta");}
  627. };
  628. #endif
  629. #endif
  630. // exa
  631. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  632. template <typename CharT>
  633. struct ratio_string<exa, CharT> :
  634. ratio_detail::ratio_string_static<exa,CharT>
  635. {};
  636. #else
  637. template <>
  638. struct ratio_string<exa, char>
  639. {
  640. static std::string symbol() {return std::string(1, 'E');}
  641. static std::string prefix() {return std::string("exa");}
  642. };
  643. #if defined BOOST_RATIO_HAS_UNICODE_SUPPORT
  644. template <>
  645. struct ratio_string<exa, char16_t>
  646. {
  647. static std::u16string symbol() {return std::u16string(1, u'E');}
  648. static std::u16string prefix() {return std::u16string(u"exa");}
  649. };
  650. template <>
  651. struct ratio_string<exa, char32_t>
  652. {
  653. static std::u32string symbol() {return std::u32string(1, U'E');}
  654. static std::u32string prefix() {return std::u32string(U"exa");}
  655. };
  656. #endif
  657. #ifndef BOOST_NO_STD_WSTRING
  658. template <>
  659. struct ratio_string<exa, wchar_t>
  660. {
  661. static std::wstring symbol() {return std::wstring(1, L'E');}
  662. static std::wstring prefix() {return std::wstring(L"exa");}
  663. };
  664. #endif
  665. #endif
  666. #ifdef BOOST_RATIO_EXTENSIONS
  667. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  668. template <typename CharT>
  669. struct ratio_string<kibi, CharT> :
  670. ratio_detail::ratio_string_static<kibi,CharT>
  671. {};
  672. #else
  673. template <>
  674. struct ratio_string<kibi, char>
  675. {
  676. static std::string symbol() {return std::string("Ki");}
  677. static std::string prefix() {return std::string("kibi");}
  678. };
  679. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  680. template <>
  681. struct ratio_string<kibi, char16_t>
  682. {
  683. static std::u16string symbol() {return std::u16string(u"Ki");}
  684. static std::u16string prefix() {return std::u16string(u"kibi");}
  685. };
  686. template <>
  687. struct ratio_string<kibi, char32_t>
  688. {
  689. static std::u32string symbol() {return std::u32string(U"Ki");}
  690. static std::u32string prefix() {return std::u32string(U"kibi");}
  691. };
  692. #endif
  693. #ifndef BOOST_NO_STD_WSTRING
  694. template <>
  695. struct ratio_string<kibi, wchar_t>
  696. {
  697. static std::wstring symbol() {return std::wstring(L"Ki");}
  698. static std::wstring prefix() {return std::wstring(L"kibi");}
  699. };
  700. #endif
  701. #endif
  702. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  703. template <typename CharT>
  704. struct ratio_string<mebi, CharT> :
  705. ratio_detail::ratio_string_static<mebi,CharT>
  706. {};
  707. #else
  708. template <>
  709. struct ratio_string<mebi, char>
  710. {
  711. static std::string symbol() {return std::string("Mi");}
  712. static std::string prefix() {return std::string("mebi");}
  713. };
  714. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  715. template <>
  716. struct ratio_string<mebi, char16_t>
  717. {
  718. static std::u16string symbol() {return std::u16string(u"Mi");}
  719. static std::u16string prefix() {return std::u16string(u"mebi");}
  720. };
  721. template <>
  722. struct ratio_string<mebi, char32_t>
  723. {
  724. static std::u32string symbol() {return std::u32string(U"Mi");}
  725. static std::u32string prefix() {return std::u32string(U"mebi");}
  726. };
  727. #endif
  728. #ifndef BOOST_NO_STD_WSTRING
  729. template <>
  730. struct ratio_string<mebi, wchar_t>
  731. {
  732. static std::wstring symbol() {return std::wstring(L"Mi");}
  733. static std::wstring prefix() {return std::wstring(L"mebi");}
  734. };
  735. #endif
  736. #endif
  737. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  738. template <typename CharT>
  739. struct ratio_string<gibi, CharT> :
  740. ratio_detail::ratio_string_static<gibi,CharT>
  741. {};
  742. #else
  743. template <>
  744. struct ratio_string<gibi, char>
  745. {
  746. static std::string symbol() {return std::string("Gi");}
  747. static std::string prefix() {return std::string("gibi");}
  748. };
  749. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  750. template <>
  751. struct ratio_string<gibi, char16_t>
  752. {
  753. static std::u16string symbol() {return std::u16string(u"Gi");}
  754. static std::u16string prefix() {return std::u16string(u"gibi");}
  755. };
  756. template <>
  757. struct ratio_string<gibi, char32_t>
  758. {
  759. static std::u32string symbol() {return std::u32string(U"Gi");}
  760. static std::u32string prefix() {return std::u32string(U"gibi");}
  761. };
  762. #endif
  763. #ifndef BOOST_NO_STD_WSTRING
  764. template <>
  765. struct ratio_string<gibi, wchar_t>
  766. {
  767. static std::wstring symbol() {return std::wstring(L"Gi");}
  768. static std::wstring prefix() {return std::wstring(L"gibi");}
  769. };
  770. #endif
  771. #endif
  772. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  773. template <typename CharT>
  774. struct ratio_string<tebi, CharT> :
  775. ratio_detail::ratio_string_static<tebi,CharT>
  776. {};
  777. #else
  778. template <>
  779. struct ratio_string<tebi, char>
  780. {
  781. static std::string symbol() {return std::string("Ti");}
  782. static std::string prefix() {return std::string("tebi");}
  783. };
  784. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  785. template <>
  786. struct ratio_string<tebi, char16_t>
  787. {
  788. static std::u16string symbol() {return std::u16string(u"Ti");}
  789. static std::u16string prefix() {return std::u16string(u"tebi");}
  790. };
  791. template <>
  792. struct ratio_string<tebi, char32_t>
  793. {
  794. static std::u32string symbol() {return std::u32string(U"Ti");}
  795. static std::u32string prefix() {return std::u32string(U"tebi");}
  796. };
  797. #endif
  798. #ifndef BOOST_NO_STD_WSTRING
  799. template <>
  800. struct ratio_string<tebi, wchar_t>
  801. {
  802. static std::wstring symbol() {return std::wstring(L"Ti");}
  803. static std::wstring prefix() {return std::wstring(L"tebi");}
  804. };
  805. #endif
  806. #endif
  807. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  808. template <typename CharT>
  809. struct ratio_string<pebi, CharT> :
  810. ratio_detail::ratio_string_static<pebi,CharT>
  811. {};
  812. #else
  813. template <>
  814. struct ratio_string<pebi, char>
  815. {
  816. static std::string symbol() {return std::string("Pi");}
  817. static std::string prefix() {return std::string("pebi");}
  818. };
  819. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  820. template <>
  821. struct ratio_string<pebi, char16_t>
  822. {
  823. static std::u16string symbol() {return std::u16string(u"Pi");}
  824. static std::u16string prefix() {return std::u16string(u"pebi");}
  825. };
  826. template <>
  827. struct ratio_string<pebi, char32_t>
  828. {
  829. static std::u32string symbol() {return std::u32string(U"Pi");}
  830. static std::u32string prefix() {return std::u32string(U"pebi");}
  831. };
  832. #endif
  833. #ifndef BOOST_NO_STD_WSTRING
  834. template <>
  835. struct ratio_string<pebi, wchar_t>
  836. {
  837. static std::wstring symbol() {return std::wstring(L"Pi");}
  838. static std::wstring prefix() {return std::wstring(L"pebi");}
  839. };
  840. #endif
  841. #endif
  842. #ifdef BOOST_RATIO_HAS_STATIC_STRING
  843. template <typename CharT>
  844. struct ratio_string<exbi, CharT> :
  845. ratio_detail::ratio_string_static<exbi,CharT>
  846. {};
  847. #else
  848. template <>
  849. struct ratio_string<exbi, char>
  850. {
  851. static std::string symbol() {return std::string("Ei");}
  852. static std::string prefix() {return std::string("exbi");}
  853. };
  854. #if BOOST_RATIO_HAS_UNICODE_SUPPORT
  855. template <>
  856. struct ratio_string<exbi, char16_t>
  857. {
  858. static std::u16string symbol() {return std::u16string(u"Ei");}
  859. static std::u16string prefix() {return std::u16string(u"exbi");}
  860. };
  861. template <>
  862. struct ratio_string<exbi, char32_t>
  863. {
  864. static std::u32string symbol() {return std::u32string(U"Ei");}
  865. static std::u32string prefix() {return std::u32string(U"exbi");}
  866. };
  867. #endif
  868. #ifndef BOOST_NO_STD_WSTRING
  869. template <>
  870. struct ratio_string<exbi, wchar_t>
  871. {
  872. static std::wstring symbol() {return std::wstring(L"Ei");}
  873. static std::wstring prefix() {return std::wstring(L"exbi");}
  874. };
  875. #endif
  876. #endif
  877. #endif
  878. }
  879. #endif // BOOST_RATIO_PROVIDES_DEPRECATED_FEATURES_SINCE_V2_0_0
  880. #endif // BOOST_RATIO_RATIO_IO_HPP