conversion.hpp 21 KB

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