conversion.hpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  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/requires_cxx11.hpp>
  8. #include <boost/endian/detail/endian_reverse.hpp>
  9. #include <boost/endian/detail/endian_load.hpp>
  10. #include <boost/endian/detail/endian_store.hpp>
  11. #include <boost/endian/detail/order.hpp>
  12. #include <boost/type_traits/is_class.hpp>
  13. #include <boost/type_traits/is_array.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. template <class EndianReversible>
  125. inline BOOST_CONSTEXPR EndianReversible big_to_native( EndianReversible x ) BOOST_NOEXCEPT
  126. {
  127. return boost::endian::conditional_reverse<order::big, order::native>( x );
  128. }
  129. template <class EndianReversible>
  130. inline BOOST_CONSTEXPR EndianReversible native_to_big( EndianReversible x ) BOOST_NOEXCEPT
  131. {
  132. return boost::endian::conditional_reverse<order::native, order::big>( x );
  133. }
  134. template <class EndianReversible>
  135. inline BOOST_CONSTEXPR EndianReversible little_to_native( EndianReversible x ) BOOST_NOEXCEPT
  136. {
  137. return boost::endian::conditional_reverse<order::little, order::native>( x );
  138. }
  139. template <class EndianReversible>
  140. inline BOOST_CONSTEXPR EndianReversible native_to_little( EndianReversible x ) BOOST_NOEXCEPT
  141. {
  142. return boost::endian::conditional_reverse<order::native, order::little>( x );
  143. }
  144. namespace detail
  145. {
  146. template<class EndianReversible>
  147. inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, boost::true_type ) BOOST_NOEXCEPT
  148. {
  149. return x;
  150. }
  151. template<class EndianReversible>
  152. inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, boost::false_type ) BOOST_NOEXCEPT
  153. {
  154. return endian_reverse( x );
  155. }
  156. } // namespace detail
  157. // generic conditional reverse
  158. template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversible>
  159. inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x ) BOOST_NOEXCEPT
  160. {
  161. BOOST_STATIC_ASSERT( boost::is_class<EndianReversible>::value || detail::is_endian_reversible<EndianReversible>::value );
  162. return detail::conditional_reverse_impl( x, boost::integral_constant<bool, From == To>() );
  163. }
  164. // runtime conditional reverse
  165. template <class EndianReversible>
  166. inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x,
  167. BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order ) BOOST_NOEXCEPT
  168. {
  169. BOOST_STATIC_ASSERT( boost::is_class<EndianReversible>::value || detail::is_endian_reversible<EndianReversible>::value );
  170. return from_order == to_order? x: endian_reverse( x );
  171. }
  172. //--------------------------------------------------------------------------------------//
  173. // reverse-in-place implementation //
  174. //--------------------------------------------------------------------------------------//
  175. template <class EndianReversibleInplace>
  176. inline void big_to_native_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
  177. {
  178. boost::endian::conditional_reverse_inplace<order::big, order::native>( x );
  179. }
  180. template <class EndianReversibleInplace>
  181. inline void native_to_big_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
  182. {
  183. boost::endian::conditional_reverse_inplace<order::native, order::big>( x );
  184. }
  185. template <class EndianReversibleInplace>
  186. inline void little_to_native_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
  187. {
  188. boost::endian::conditional_reverse_inplace<order::little, order::native>( x );
  189. }
  190. template <class EndianReversibleInplace>
  191. inline void native_to_little_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
  192. {
  193. boost::endian::conditional_reverse_inplace<order::native, order::little>( x );
  194. }
  195. namespace detail
  196. {
  197. template<class EndianReversibleInplace>
  198. inline void conditional_reverse_inplace_impl( EndianReversibleInplace&, boost::true_type ) BOOST_NOEXCEPT
  199. {
  200. }
  201. template<class EndianReversibleInplace>
  202. inline void conditional_reverse_inplace_impl( EndianReversibleInplace& x, boost::false_type ) BOOST_NOEXCEPT
  203. {
  204. endian_reverse_inplace( x );
  205. }
  206. } // namespace detail
  207. // generic conditional reverse in place
  208. template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversibleInplace>
  209. inline void conditional_reverse_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
  210. {
  211. BOOST_STATIC_ASSERT(
  212. boost::is_class<EndianReversibleInplace>::value ||
  213. boost::is_array<EndianReversibleInplace>::value ||
  214. detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
  215. detail::conditional_reverse_inplace_impl( x, boost::integral_constant<bool, From == To>() );
  216. }
  217. // runtime reverse in place
  218. template <class EndianReversibleInplace>
  219. inline void conditional_reverse_inplace( EndianReversibleInplace& x,
  220. BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order ) BOOST_NOEXCEPT
  221. {
  222. BOOST_STATIC_ASSERT(
  223. boost::is_class<EndianReversibleInplace>::value ||
  224. boost::is_array<EndianReversibleInplace>::value ||
  225. detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
  226. if( from_order != to_order )
  227. {
  228. endian_reverse_inplace( x );
  229. }
  230. }
  231. // load/store convenience functions
  232. // load 16
  233. inline boost::int16_t load_little_s16( unsigned char const * p ) BOOST_NOEXCEPT
  234. {
  235. return boost::endian::endian_load<boost::int16_t, 2, order::little>( p );
  236. }
  237. inline boost::uint16_t load_little_u16( unsigned char const * p ) BOOST_NOEXCEPT
  238. {
  239. return boost::endian::endian_load<boost::uint16_t, 2, order::little>( p );
  240. }
  241. inline boost::int16_t load_big_s16( unsigned char const * p ) BOOST_NOEXCEPT
  242. {
  243. return boost::endian::endian_load<boost::int16_t, 2, order::big>( p );
  244. }
  245. inline boost::uint16_t load_big_u16( unsigned char const * p ) BOOST_NOEXCEPT
  246. {
  247. return boost::endian::endian_load<boost::uint16_t, 2, order::big>( p );
  248. }
  249. // load 24
  250. inline boost::int32_t load_little_s24( unsigned char const * p ) BOOST_NOEXCEPT
  251. {
  252. return boost::endian::endian_load<boost::int32_t, 3, order::little>( p );
  253. }
  254. inline boost::uint32_t load_little_u24( unsigned char const * p ) BOOST_NOEXCEPT
  255. {
  256. return boost::endian::endian_load<boost::uint32_t, 3, order::little>( p );
  257. }
  258. inline boost::int32_t load_big_s24( unsigned char const * p ) BOOST_NOEXCEPT
  259. {
  260. return boost::endian::endian_load<boost::int32_t, 3, order::big>( p );
  261. }
  262. inline boost::uint32_t load_big_u24( unsigned char const * p ) BOOST_NOEXCEPT
  263. {
  264. return boost::endian::endian_load<boost::uint32_t, 3, order::big>( p );
  265. }
  266. // load 32
  267. inline boost::int32_t load_little_s32( unsigned char const * p ) BOOST_NOEXCEPT
  268. {
  269. return boost::endian::endian_load<boost::int32_t, 4, order::little>( p );
  270. }
  271. inline boost::uint32_t load_little_u32( unsigned char const * p ) BOOST_NOEXCEPT
  272. {
  273. return boost::endian::endian_load<boost::uint32_t, 4, order::little>( p );
  274. }
  275. inline boost::int32_t load_big_s32( unsigned char const * p ) BOOST_NOEXCEPT
  276. {
  277. return boost::endian::endian_load<boost::int32_t, 4, order::big>( p );
  278. }
  279. inline boost::uint32_t load_big_u32( unsigned char const * p ) BOOST_NOEXCEPT
  280. {
  281. return boost::endian::endian_load<boost::uint32_t, 4, order::big>( p );
  282. }
  283. // load 40
  284. inline boost::int64_t load_little_s40( unsigned char const * p ) BOOST_NOEXCEPT
  285. {
  286. return boost::endian::endian_load<boost::int64_t, 5, order::little>( p );
  287. }
  288. inline boost::uint64_t load_little_u40( unsigned char const * p ) BOOST_NOEXCEPT
  289. {
  290. return boost::endian::endian_load<boost::uint64_t, 5, order::little>( p );
  291. }
  292. inline boost::int64_t load_big_s40( unsigned char const * p ) BOOST_NOEXCEPT
  293. {
  294. return boost::endian::endian_load<boost::int64_t, 5, order::big>( p );
  295. }
  296. inline boost::uint64_t load_big_u40( unsigned char const * p ) BOOST_NOEXCEPT
  297. {
  298. return boost::endian::endian_load<boost::uint64_t, 5, order::big>( p );
  299. }
  300. // load 48
  301. inline boost::int64_t load_little_s48( unsigned char const * p ) BOOST_NOEXCEPT
  302. {
  303. return boost::endian::endian_load<boost::int64_t, 6, order::little>( p );
  304. }
  305. inline boost::uint64_t load_little_u48( unsigned char const * p ) BOOST_NOEXCEPT
  306. {
  307. return boost::endian::endian_load<boost::uint64_t, 6, order::little>( p );
  308. }
  309. inline boost::int64_t load_big_s48( unsigned char const * p ) BOOST_NOEXCEPT
  310. {
  311. return boost::endian::endian_load<boost::int64_t, 6, order::big>( p );
  312. }
  313. inline boost::uint64_t load_big_u48( unsigned char const * p ) BOOST_NOEXCEPT
  314. {
  315. return boost::endian::endian_load<boost::uint64_t, 6, order::big>( p );
  316. }
  317. // load 56
  318. inline boost::int64_t load_little_s56( unsigned char const * p ) BOOST_NOEXCEPT
  319. {
  320. return boost::endian::endian_load<boost::int64_t, 7, order::little>( p );
  321. }
  322. inline boost::uint64_t load_little_u56( unsigned char const * p ) BOOST_NOEXCEPT
  323. {
  324. return boost::endian::endian_load<boost::uint64_t, 7, order::little>( p );
  325. }
  326. inline boost::int64_t load_big_s56( unsigned char const * p ) BOOST_NOEXCEPT
  327. {
  328. return boost::endian::endian_load<boost::int64_t, 7, order::big>( p );
  329. }
  330. inline boost::uint64_t load_big_u56( unsigned char const * p ) BOOST_NOEXCEPT
  331. {
  332. return boost::endian::endian_load<boost::uint64_t, 7, order::big>( p );
  333. }
  334. // load 64
  335. inline boost::int64_t load_little_s64( unsigned char const * p ) BOOST_NOEXCEPT
  336. {
  337. return boost::endian::endian_load<boost::int64_t, 8, order::little>( p );
  338. }
  339. inline boost::uint64_t load_little_u64( unsigned char const * p ) BOOST_NOEXCEPT
  340. {
  341. return boost::endian::endian_load<boost::uint64_t, 8, order::little>( p );
  342. }
  343. inline boost::int64_t load_big_s64( unsigned char const * p ) BOOST_NOEXCEPT
  344. {
  345. return boost::endian::endian_load<boost::int64_t, 8, order::big>( p );
  346. }
  347. inline boost::uint64_t load_big_u64( unsigned char const * p ) BOOST_NOEXCEPT
  348. {
  349. return boost::endian::endian_load<boost::uint64_t, 8, order::big>( p );
  350. }
  351. // store 16
  352. inline void store_little_s16( unsigned char * p, boost::int16_t v )
  353. {
  354. boost::endian::endian_store<boost::int16_t, 2, order::little>( p, v );
  355. }
  356. inline void store_little_u16( unsigned char * p, boost::uint16_t v )
  357. {
  358. boost::endian::endian_store<boost::uint16_t, 2, order::little>( p, v );
  359. }
  360. inline void store_big_s16( unsigned char * p, boost::int16_t v )
  361. {
  362. boost::endian::endian_store<boost::int16_t, 2, order::big>( p, v );
  363. }
  364. inline void store_big_u16( unsigned char * p, boost::uint16_t v )
  365. {
  366. boost::endian::endian_store<boost::uint16_t, 2, order::big>( p, v );
  367. }
  368. // store 24
  369. inline void store_little_s24( unsigned char * p, boost::int32_t v )
  370. {
  371. boost::endian::endian_store<boost::int32_t, 3, order::little>( p, v );
  372. }
  373. inline void store_little_u24( unsigned char * p, boost::uint32_t v )
  374. {
  375. boost::endian::endian_store<boost::uint32_t, 3, order::little>( p, v );
  376. }
  377. inline void store_big_s24( unsigned char * p, boost::int32_t v )
  378. {
  379. boost::endian::endian_store<boost::int32_t, 3, order::big>( p, v );
  380. }
  381. inline void store_big_u24( unsigned char * p, boost::uint32_t v )
  382. {
  383. boost::endian::endian_store<boost::uint32_t, 3, order::big>( p, v );
  384. }
  385. // store 32
  386. inline void store_little_s32( unsigned char * p, boost::int32_t v )
  387. {
  388. boost::endian::endian_store<boost::int32_t, 4, order::little>( p, v );
  389. }
  390. inline void store_little_u32( unsigned char * p, boost::uint32_t v )
  391. {
  392. boost::endian::endian_store<boost::uint32_t, 4, order::little>( p, v );
  393. }
  394. inline void store_big_s32( unsigned char * p, boost::int32_t v )
  395. {
  396. boost::endian::endian_store<boost::int32_t, 4, order::big>( p, v );
  397. }
  398. inline void store_big_u32( unsigned char * p, boost::uint32_t v )
  399. {
  400. boost::endian::endian_store<boost::uint32_t, 4, order::big>( p, v );
  401. }
  402. // store 40
  403. inline void store_little_s40( unsigned char * p, boost::int64_t v )
  404. {
  405. boost::endian::endian_store<boost::int64_t, 5, order::little>( p, v );
  406. }
  407. inline void store_little_u40( unsigned char * p, boost::uint64_t v )
  408. {
  409. boost::endian::endian_store<boost::uint64_t, 5, order::little>( p, v );
  410. }
  411. inline void store_big_s40( unsigned char * p, boost::int64_t v )
  412. {
  413. boost::endian::endian_store<boost::int64_t, 5, order::big>( p, v );
  414. }
  415. inline void store_big_u40( unsigned char * p, boost::uint64_t v )
  416. {
  417. boost::endian::endian_store<boost::uint64_t, 5, order::big>( p, v );
  418. }
  419. // store 48
  420. inline void store_little_s48( unsigned char * p, boost::int64_t v )
  421. {
  422. boost::endian::endian_store<boost::int64_t, 6, order::little>( p, v );
  423. }
  424. inline void store_little_u48( unsigned char * p, boost::uint64_t v )
  425. {
  426. boost::endian::endian_store<boost::uint64_t, 6, order::little>( p, v );
  427. }
  428. inline void store_big_s48( unsigned char * p, boost::int64_t v )
  429. {
  430. boost::endian::endian_store<boost::int64_t, 6, order::big>( p, v );
  431. }
  432. inline void store_big_u48( unsigned char * p, boost::uint64_t v )
  433. {
  434. boost::endian::endian_store<boost::uint64_t, 6, order::big>( p, v );
  435. }
  436. // store 56
  437. inline void store_little_s56( unsigned char * p, boost::int64_t v )
  438. {
  439. boost::endian::endian_store<boost::int64_t, 7, order::little>( p, v );
  440. }
  441. inline void store_little_u56( unsigned char * p, boost::uint64_t v )
  442. {
  443. boost::endian::endian_store<boost::uint64_t, 7, order::little>( p, v );
  444. }
  445. inline void store_big_s56( unsigned char * p, boost::int64_t v )
  446. {
  447. boost::endian::endian_store<boost::int64_t, 7, order::big>( p, v );
  448. }
  449. inline void store_big_u56( unsigned char * p, boost::uint64_t v )
  450. {
  451. boost::endian::endian_store<boost::uint64_t, 7, order::big>( p, v );
  452. }
  453. // store 64
  454. inline void store_little_s64( unsigned char * p, boost::int64_t v )
  455. {
  456. boost::endian::endian_store<boost::int64_t, 8, order::little>( p, v );
  457. }
  458. inline void store_little_u64( unsigned char * p, boost::uint64_t v )
  459. {
  460. boost::endian::endian_store<boost::uint64_t, 8, order::little>( p, v );
  461. }
  462. inline void store_big_s64( unsigned char * p, boost::int64_t v )
  463. {
  464. boost::endian::endian_store<boost::int64_t, 8, order::big>( p, v );
  465. }
  466. inline void store_big_u64( unsigned char * p, boost::uint64_t v )
  467. {
  468. boost::endian::endian_store<boost::uint64_t, 8, order::big>( p, v );
  469. }
  470. } // namespace endian
  471. } // namespace boost
  472. #endif // BOOST_ENDIAN_CONVERSION_HPP