conversion.hpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. // boost/endian/conversion.hpp -------------------------------------------------------//
  2. // Copyright Beman Dawes 2010, 2011, 2014
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // http://www.boost.org/LICENSE_1_0.txt
  5. #ifndef BOOST_ENDIAN_CONVERSION_HPP
  6. #define BOOST_ENDIAN_CONVERSION_HPP
  7. #include <boost/endian/detail/endian_reverse.hpp>
  8. #include <boost/endian/detail/endian_load.hpp>
  9. #include <boost/endian/detail/endian_store.hpp>
  10. #include <boost/endian/detail/order.hpp>
  11. #include <boost/type_traits/is_class.hpp>
  12. #include <boost/type_traits/is_integral.hpp>
  13. #include <boost/type_traits/is_same.hpp>
  14. #include <boost/type_traits/integral_constant.hpp>
  15. #include <boost/static_assert.hpp>
  16. #include <boost/cstdint.hpp>
  17. #include <boost/config.hpp>
  18. //------------------------------------- synopsis ---------------------------------------//
  19. namespace boost
  20. {
  21. namespace endian
  22. {
  23. //--------------------------------------------------------------------------------------//
  24. // //
  25. // return-by-value interfaces //
  26. // suggested by Phil Endecott //
  27. // //
  28. // user-defined types (UDTs) //
  29. // //
  30. // All return-by-value conversion function templates are required to be implemented in //
  31. // terms of an unqualified call to "endian_reverse(x)", a function returning the //
  32. // value of x with endianness reversed. This provides a customization point for any //
  33. // UDT that provides a "endian_reverse" free-function meeting the requirements. //
  34. // It must be defined in the same namespace as the UDT itself so that it will be found //
  35. // by argument dependent lookup (ADL). //
  36. // //
  37. //--------------------------------------------------------------------------------------//
  38. // reverse byte order
  39. // requires T to be a non-bool integral type
  40. // in detail/endian_reverse.hpp
  41. //
  42. // template<class T> inline BOOST_CONSTEXPR T endian_reverse( T x ) BOOST_NOEXCEPT;
  43. // reverse byte order unless native endianness is big
  44. template <class EndianReversible >
  45. inline BOOST_CONSTEXPR EndianReversible big_to_native(EndianReversible x) BOOST_NOEXCEPT;
  46. // Returns: x if native endian order is big, otherwise endian_reverse(x)
  47. template <class EndianReversible >
  48. inline BOOST_CONSTEXPR EndianReversible native_to_big(EndianReversible x) BOOST_NOEXCEPT;
  49. // Returns: x if native endian order is big, otherwise endian_reverse(x)
  50. // reverse byte order unless native endianness is little
  51. template <class EndianReversible >
  52. inline BOOST_CONSTEXPR EndianReversible little_to_native(EndianReversible x) BOOST_NOEXCEPT;
  53. // Returns: x if native endian order is little, otherwise endian_reverse(x)
  54. template <class EndianReversible >
  55. inline BOOST_CONSTEXPR EndianReversible native_to_little(EndianReversible x) BOOST_NOEXCEPT;
  56. // Returns: x if native endian order is little, otherwise endian_reverse(x)
  57. // generic conditional reverse byte order
  58. template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To,
  59. class EndianReversible>
  60. inline BOOST_CONSTEXPR EndianReversible conditional_reverse(EndianReversible from) BOOST_NOEXCEPT;
  61. // Returns: If From == To have different values, from.
  62. // Otherwise endian_reverse(from).
  63. // Remarks: The From == To test, and as a consequence which form the return takes, is
  64. // is determined at compile time.
  65. // runtime conditional reverse byte order
  66. template <class EndianReversible >
  67. inline BOOST_CONSTEXPR EndianReversible conditional_reverse(EndianReversible from,
  68. BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order)
  69. BOOST_NOEXCEPT;
  70. // Returns: from_order == to_order ? from : endian_reverse(from).
  71. //------------------------------------------------------------------------------------//
  72. // Q: What happened to bswap, htobe, and the other synonym functions based on names
  73. // popularized by BSD, OS X, and Linux?
  74. // A: Turned out these may be implemented as macros on some systems. Ditto POSIX names
  75. // for such functionality. Since macros would cause endless problems with functions
  76. // of the same names, and these functions are just synonyms anyhow, they have been
  77. // removed.
  78. //------------------------------------------------------------------------------------//
  79. // //
  80. // reverse in place interfaces //
  81. // //
  82. // user-defined types (UDTs) //
  83. // //
  84. // All reverse in place function templates are required to be implemented in terms //
  85. // of an unqualified call to "endian_reverse_inplace(x)", a function reversing //
  86. // the endianness of x, which is a non-const reference. This provides a //
  87. // customization point for any UDT that provides a "reverse_inplace" free-function //
  88. // meeting the requirements. The free-function must be declared in the same //
  89. // namespace as the UDT itself so that it will be found by argument-dependent //
  90. // lookup (ADL). //
  91. // //
  92. //------------------------------------------------------------------------------------//
  93. // reverse in place
  94. // in detail/endian_reverse.hpp
  95. //
  96. // template <class EndianReversible>
  97. // inline void endian_reverse_inplace(EndianReversible& x) BOOST_NOEXCEPT;
  98. //
  99. // Effects: x = endian_reverse(x)
  100. // reverse in place unless native endianness is big
  101. template <class EndianReversibleInplace>
  102. inline void big_to_native_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
  103. // Effects: none if native byte-order is big, otherwise endian_reverse_inplace(x)
  104. template <class EndianReversibleInplace>
  105. inline void native_to_big_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
  106. // Effects: none if native byte-order is big, otherwise endian_reverse_inplace(x)
  107. // reverse in place unless native endianness is little
  108. template <class EndianReversibleInplace>
  109. inline void little_to_native_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
  110. // Effects: none if native byte-order is little, otherwise endian_reverse_inplace(x);
  111. template <class EndianReversibleInplace>
  112. inline void native_to_little_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
  113. // Effects: none if native byte-order is little, otherwise endian_reverse_inplace(x);
  114. // generic conditional reverse in place
  115. template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To,
  116. class EndianReversibleInplace>
  117. inline void conditional_reverse_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
  118. // runtime reverse in place
  119. template <class EndianReversibleInplace>
  120. inline void conditional_reverse_inplace(EndianReversibleInplace& x,
  121. BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order)
  122. BOOST_NOEXCEPT;
  123. //----------------------------------- end synopsis -------------------------------------//
  124. namespace detail
  125. {
  126. template<class T> struct is_endian_reversible: boost::integral_constant<bool,
  127. boost::is_class<T>::value || ( boost::is_integral<T>::value && !boost::is_same<T, bool>::value )>
  128. {
  129. };
  130. } // namespace detail
  131. template <class EndianReversible>
  132. inline BOOST_CONSTEXPR EndianReversible big_to_native( EndianReversible x ) BOOST_NOEXCEPT
  133. {
  134. return boost::endian::conditional_reverse<order::big, order::native>( x );
  135. }
  136. template <class EndianReversible>
  137. inline BOOST_CONSTEXPR EndianReversible native_to_big( EndianReversible x ) BOOST_NOEXCEPT
  138. {
  139. return boost::endian::conditional_reverse<order::native, order::big>( x );
  140. }
  141. template <class EndianReversible>
  142. inline BOOST_CONSTEXPR EndianReversible little_to_native( EndianReversible x ) BOOST_NOEXCEPT
  143. {
  144. return boost::endian::conditional_reverse<order::little, order::native>( x );
  145. }
  146. template <class EndianReversible>
  147. inline BOOST_CONSTEXPR EndianReversible native_to_little( EndianReversible x ) BOOST_NOEXCEPT
  148. {
  149. return boost::endian::conditional_reverse<order::native, order::little>( x );
  150. }
  151. namespace detail
  152. {
  153. template<class EndianReversible>
  154. inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, boost::true_type ) BOOST_NOEXCEPT
  155. {
  156. return x;
  157. }
  158. template<class EndianReversible>
  159. inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, boost::false_type ) BOOST_NOEXCEPT
  160. {
  161. return endian_reverse( x );
  162. }
  163. } // namespace detail
  164. // generic conditional reverse
  165. template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversible>
  166. inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x ) BOOST_NOEXCEPT
  167. {
  168. BOOST_STATIC_ASSERT( detail::is_endian_reversible<EndianReversible>::value );
  169. return detail::conditional_reverse_impl( x, boost::integral_constant<bool, From == To>() );
  170. }
  171. // runtime conditional reverse
  172. template <class EndianReversible>
  173. inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x,
  174. BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order ) BOOST_NOEXCEPT
  175. {
  176. BOOST_STATIC_ASSERT( detail::is_endian_reversible<EndianReversible>::value );
  177. return from_order == to_order? x: endian_reverse( x );
  178. }
  179. //--------------------------------------------------------------------------------------//
  180. // reverse-in-place implementation //
  181. //--------------------------------------------------------------------------------------//
  182. namespace detail
  183. {
  184. template<class T> struct is_endian_reversible_inplace: boost::integral_constant<bool,
  185. boost::is_class<T>::value || ( boost::is_integral<T>::value && !boost::is_same<T, bool>::value )>
  186. {
  187. };
  188. } // namespace detail
  189. template <class EndianReversibleInplace>
  190. inline void big_to_native_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
  191. {
  192. boost::endian::conditional_reverse_inplace<order::big, order::native>( x );
  193. }
  194. template <class EndianReversibleInplace>
  195. inline void native_to_big_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
  196. {
  197. boost::endian::conditional_reverse_inplace<order::native, order::big>( x );
  198. }
  199. template <class EndianReversibleInplace>
  200. inline void little_to_native_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
  201. {
  202. boost::endian::conditional_reverse_inplace<order::little, order::native>( x );
  203. }
  204. template <class EndianReversibleInplace>
  205. inline void native_to_little_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
  206. {
  207. boost::endian::conditional_reverse_inplace<order::native, order::little>( x );
  208. }
  209. namespace detail
  210. {
  211. template<class EndianReversibleInplace>
  212. inline void conditional_reverse_inplace_impl( EndianReversibleInplace&, boost::true_type ) BOOST_NOEXCEPT
  213. {
  214. }
  215. template<class EndianReversibleInplace>
  216. inline void conditional_reverse_inplace_impl( EndianReversibleInplace& x, boost::false_type ) BOOST_NOEXCEPT
  217. {
  218. endian_reverse_inplace( x );
  219. }
  220. } // namespace detail
  221. // generic conditional reverse in place
  222. template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversibleInplace>
  223. inline void conditional_reverse_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
  224. {
  225. BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
  226. detail::conditional_reverse_inplace_impl( x, boost::integral_constant<bool, From == To>() );
  227. }
  228. // runtime reverse in place
  229. template <class EndianReversibleInplace>
  230. inline void conditional_reverse_inplace( EndianReversibleInplace& x,
  231. BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order ) BOOST_NOEXCEPT
  232. {
  233. BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
  234. if( from_order != to_order )
  235. {
  236. endian_reverse_inplace( x );
  237. }
  238. }
  239. // load/store convenience functions
  240. // load 16
  241. inline boost::int16_t load_little_s16( unsigned char const * p ) BOOST_NOEXCEPT
  242. {
  243. return boost::endian::endian_load<boost::int16_t, 2, order::little>( p );
  244. }
  245. inline boost::uint16_t load_little_u16( unsigned char const * p ) BOOST_NOEXCEPT
  246. {
  247. return boost::endian::endian_load<boost::uint16_t, 2, order::little>( p );
  248. }
  249. inline boost::int16_t load_big_s16( unsigned char const * p ) BOOST_NOEXCEPT
  250. {
  251. return boost::endian::endian_load<boost::int16_t, 2, order::big>( p );
  252. }
  253. inline boost::uint16_t load_big_u16( unsigned char const * p ) BOOST_NOEXCEPT
  254. {
  255. return boost::endian::endian_load<boost::uint16_t, 2, order::big>( p );
  256. }
  257. // load 24
  258. inline boost::int32_t load_little_s24( unsigned char const * p ) BOOST_NOEXCEPT
  259. {
  260. return boost::endian::endian_load<boost::int32_t, 3, order::little>( p );
  261. }
  262. inline boost::uint32_t load_little_u24( unsigned char const * p ) BOOST_NOEXCEPT
  263. {
  264. return boost::endian::endian_load<boost::uint32_t, 3, order::little>( p );
  265. }
  266. inline boost::int32_t load_big_s24( unsigned char const * p ) BOOST_NOEXCEPT
  267. {
  268. return boost::endian::endian_load<boost::int32_t, 3, order::big>( p );
  269. }
  270. inline boost::uint32_t load_big_u24( unsigned char const * p ) BOOST_NOEXCEPT
  271. {
  272. return boost::endian::endian_load<boost::uint32_t, 3, order::big>( p );
  273. }
  274. // load 32
  275. inline boost::int32_t load_little_s32( unsigned char const * p ) BOOST_NOEXCEPT
  276. {
  277. return boost::endian::endian_load<boost::int32_t, 4, order::little>( p );
  278. }
  279. inline boost::uint32_t load_little_u32( unsigned char const * p ) BOOST_NOEXCEPT
  280. {
  281. return boost::endian::endian_load<boost::uint32_t, 4, order::little>( p );
  282. }
  283. inline boost::int32_t load_big_s32( unsigned char const * p ) BOOST_NOEXCEPT
  284. {
  285. return boost::endian::endian_load<boost::int32_t, 4, order::big>( p );
  286. }
  287. inline boost::uint32_t load_big_u32( unsigned char const * p ) BOOST_NOEXCEPT
  288. {
  289. return boost::endian::endian_load<boost::uint32_t, 4, order::big>( p );
  290. }
  291. // load 40
  292. inline boost::int64_t load_little_s40( unsigned char const * p ) BOOST_NOEXCEPT
  293. {
  294. return boost::endian::endian_load<boost::int64_t, 5, order::little>( p );
  295. }
  296. inline boost::uint64_t load_little_u40( unsigned char const * p ) BOOST_NOEXCEPT
  297. {
  298. return boost::endian::endian_load<boost::uint64_t, 5, order::little>( p );
  299. }
  300. inline boost::int64_t load_big_s40( unsigned char const * p ) BOOST_NOEXCEPT
  301. {
  302. return boost::endian::endian_load<boost::int64_t, 5, order::big>( p );
  303. }
  304. inline boost::uint64_t load_big_u40( unsigned char const * p ) BOOST_NOEXCEPT
  305. {
  306. return boost::endian::endian_load<boost::uint64_t, 5, order::big>( p );
  307. }
  308. // load 48
  309. inline boost::int64_t load_little_s48( unsigned char const * p ) BOOST_NOEXCEPT
  310. {
  311. return boost::endian::endian_load<boost::int64_t, 6, order::little>( p );
  312. }
  313. inline boost::uint64_t load_little_u48( unsigned char const * p ) BOOST_NOEXCEPT
  314. {
  315. return boost::endian::endian_load<boost::uint64_t, 6, order::little>( p );
  316. }
  317. inline boost::int64_t load_big_s48( unsigned char const * p ) BOOST_NOEXCEPT
  318. {
  319. return boost::endian::endian_load<boost::int64_t, 6, order::big>( p );
  320. }
  321. inline boost::uint64_t load_big_u48( unsigned char const * p ) BOOST_NOEXCEPT
  322. {
  323. return boost::endian::endian_load<boost::uint64_t, 6, order::big>( p );
  324. }
  325. // load 56
  326. inline boost::int64_t load_little_s56( unsigned char const * p ) BOOST_NOEXCEPT
  327. {
  328. return boost::endian::endian_load<boost::int64_t, 7, order::little>( p );
  329. }
  330. inline boost::uint64_t load_little_u56( unsigned char const * p ) BOOST_NOEXCEPT
  331. {
  332. return boost::endian::endian_load<boost::uint64_t, 7, order::little>( p );
  333. }
  334. inline boost::int64_t load_big_s56( unsigned char const * p ) BOOST_NOEXCEPT
  335. {
  336. return boost::endian::endian_load<boost::int64_t, 7, order::big>( p );
  337. }
  338. inline boost::uint64_t load_big_u56( unsigned char const * p ) BOOST_NOEXCEPT
  339. {
  340. return boost::endian::endian_load<boost::uint64_t, 7, order::big>( p );
  341. }
  342. // load 64
  343. inline boost::int64_t load_little_s64( unsigned char const * p ) BOOST_NOEXCEPT
  344. {
  345. return boost::endian::endian_load<boost::int64_t, 8, order::little>( p );
  346. }
  347. inline boost::uint64_t load_little_u64( unsigned char const * p ) BOOST_NOEXCEPT
  348. {
  349. return boost::endian::endian_load<boost::uint64_t, 8, order::little>( p );
  350. }
  351. inline boost::int64_t load_big_s64( unsigned char const * p ) BOOST_NOEXCEPT
  352. {
  353. return boost::endian::endian_load<boost::int64_t, 8, order::big>( p );
  354. }
  355. inline boost::uint64_t load_big_u64( unsigned char const * p ) BOOST_NOEXCEPT
  356. {
  357. return boost::endian::endian_load<boost::uint64_t, 8, order::big>( p );
  358. }
  359. // store 16
  360. inline void store_little_s16( unsigned char * p, boost::int16_t v )
  361. {
  362. boost::endian::endian_store<boost::int16_t, 2, order::little>( p, v );
  363. }
  364. inline void store_little_u16( unsigned char * p, boost::uint16_t v )
  365. {
  366. boost::endian::endian_store<boost::uint16_t, 2, order::little>( p, v );
  367. }
  368. inline void store_big_s16( unsigned char * p, boost::int16_t v )
  369. {
  370. boost::endian::endian_store<boost::int16_t, 2, order::big>( p, v );
  371. }
  372. inline void store_big_u16( unsigned char * p, boost::uint16_t v )
  373. {
  374. boost::endian::endian_store<boost::uint16_t, 2, order::big>( p, v );
  375. }
  376. // store 24
  377. inline void store_little_s24( unsigned char * p, boost::int32_t v )
  378. {
  379. boost::endian::endian_store<boost::int32_t, 3, order::little>( p, v );
  380. }
  381. inline void store_little_u24( unsigned char * p, boost::uint32_t v )
  382. {
  383. boost::endian::endian_store<boost::uint32_t, 3, order::little>( p, v );
  384. }
  385. inline void store_big_s24( unsigned char * p, boost::int32_t v )
  386. {
  387. boost::endian::endian_store<boost::int32_t, 3, order::big>( p, v );
  388. }
  389. inline void store_big_u24( unsigned char * p, boost::uint32_t v )
  390. {
  391. boost::endian::endian_store<boost::uint32_t, 3, order::big>( p, v );
  392. }
  393. // store 32
  394. inline void store_little_s32( unsigned char * p, boost::int32_t v )
  395. {
  396. boost::endian::endian_store<boost::int32_t, 4, order::little>( p, v );
  397. }
  398. inline void store_little_u32( unsigned char * p, boost::uint32_t v )
  399. {
  400. boost::endian::endian_store<boost::uint32_t, 4, order::little>( p, v );
  401. }
  402. inline void store_big_s32( unsigned char * p, boost::int32_t v )
  403. {
  404. boost::endian::endian_store<boost::int32_t, 4, order::big>( p, v );
  405. }
  406. inline void store_big_u32( unsigned char * p, boost::uint32_t v )
  407. {
  408. boost::endian::endian_store<boost::uint32_t, 4, order::big>( p, v );
  409. }
  410. // store 40
  411. inline void store_little_s40( unsigned char * p, boost::int64_t v )
  412. {
  413. boost::endian::endian_store<boost::int64_t, 5, order::little>( p, v );
  414. }
  415. inline void store_little_u40( unsigned char * p, boost::uint64_t v )
  416. {
  417. boost::endian::endian_store<boost::uint64_t, 5, order::little>( p, v );
  418. }
  419. inline void store_big_s40( unsigned char * p, boost::int64_t v )
  420. {
  421. boost::endian::endian_store<boost::int64_t, 5, order::big>( p, v );
  422. }
  423. inline void store_big_u40( unsigned char * p, boost::uint64_t v )
  424. {
  425. boost::endian::endian_store<boost::uint64_t, 5, order::big>( p, v );
  426. }
  427. // store 48
  428. inline void store_little_s48( unsigned char * p, boost::int64_t v )
  429. {
  430. boost::endian::endian_store<boost::int64_t, 6, order::little>( p, v );
  431. }
  432. inline void store_little_u48( unsigned char * p, boost::uint64_t v )
  433. {
  434. boost::endian::endian_store<boost::uint64_t, 6, order::little>( p, v );
  435. }
  436. inline void store_big_s48( unsigned char * p, boost::int64_t v )
  437. {
  438. boost::endian::endian_store<boost::int64_t, 6, order::big>( p, v );
  439. }
  440. inline void store_big_u48( unsigned char * p, boost::uint64_t v )
  441. {
  442. boost::endian::endian_store<boost::uint64_t, 6, order::big>( p, v );
  443. }
  444. // store 56
  445. inline void store_little_s56( unsigned char * p, boost::int64_t v )
  446. {
  447. boost::endian::endian_store<boost::int64_t, 7, order::little>( p, v );
  448. }
  449. inline void store_little_u56( unsigned char * p, boost::uint64_t v )
  450. {
  451. boost::endian::endian_store<boost::uint64_t, 7, order::little>( p, v );
  452. }
  453. inline void store_big_s56( unsigned char * p, boost::int64_t v )
  454. {
  455. boost::endian::endian_store<boost::int64_t, 7, order::big>( p, v );
  456. }
  457. inline void store_big_u56( unsigned char * p, boost::uint64_t v )
  458. {
  459. boost::endian::endian_store<boost::uint64_t, 7, order::big>( p, v );
  460. }
  461. // store 64
  462. inline void store_little_s64( unsigned char * p, boost::int64_t v )
  463. {
  464. boost::endian::endian_store<boost::int64_t, 8, order::little>( p, v );
  465. }
  466. inline void store_little_u64( unsigned char * p, boost::uint64_t v )
  467. {
  468. boost::endian::endian_store<boost::uint64_t, 8, order::little>( p, v );
  469. }
  470. inline void store_big_s64( unsigned char * p, boost::int64_t v )
  471. {
  472. boost::endian::endian_store<boost::int64_t, 8, order::big>( p, v );
  473. }
  474. inline void store_big_u64( unsigned char * p, boost::uint64_t v )
  475. {
  476. boost::endian::endian_store<boost::uint64_t, 8, order::big>( p, v );
  477. }
  478. } // namespace endian
  479. } // namespace boost
  480. #endif // BOOST_ENDIAN_CONVERSION_HPP