1 //  boost/endian/conversion.hpp  -------------------------------------------------------//
2 
3 //  Copyright Beman Dawes 2010, 2011, 2014
4 
5 //  Distributed under the Boost Software License, Version 1.0.
6 //  http://www.boost.org/LICENSE_1_0.txt
7 
8 #ifndef BOOST_ENDIAN_CONVERSION_HPP
9 #define BOOST_ENDIAN_CONVERSION_HPP
10 
11 #include <boost/endian/detail/endian_reverse.hpp>
12 #include <boost/endian/detail/endian_load.hpp>
13 #include <boost/endian/detail/endian_store.hpp>
14 #include <boost/endian/detail/order.hpp>
15 #include <boost/type_traits/is_class.hpp>
16 #include <boost/type_traits/is_integral.hpp>
17 #include <boost/type_traits/is_same.hpp>
18 #include <boost/type_traits/integral_constant.hpp>
19 #include <boost/predef/other/endian.h>
20 #include <boost/static_assert.hpp>
21 #include <boost/cstdint.hpp>
22 #include <boost/config.hpp>
23 
24 //------------------------------------- synopsis ---------------------------------------//
25 
26 namespace boost
27 {
28 namespace endian
29 {
30 
31 //--------------------------------------------------------------------------------------//
32 //                                                                                      //
33 //                             return-by-value interfaces                               //
34 //                             suggested by Phil Endecott                               //
35 //                                                                                      //
36 //                             user-defined types (UDTs)                                //
37 //                                                                                      //
38 //  All return-by-value conversion function templates are required to be implemented in //
39 //  terms of an unqualified call to "endian_reverse(x)", a function returning the       //
40 //  value of x with endianness reversed. This provides a customization point for any    //
41 //  UDT that provides a "endian_reverse" free-function meeting the requirements.        //
42 //  It must be defined in the same namespace as the UDT itself so that it will be found //
43 //  by argument dependent lookup (ADL).                                                 //
44 //                                                                                      //
45 //--------------------------------------------------------------------------------------//
46 
47   //  reverse byte order
48   //  requires T to be a non-bool integral type
49   //  in detail/endian_reverse.hpp
50   template<class T> inline BOOST_CONSTEXPR T endian_reverse( T x ) BOOST_NOEXCEPT;
51 
52   //  reverse byte order unless native endianness is big
53   template <class EndianReversible >
54     inline BOOST_CONSTEXPR EndianReversible big_to_native(EndianReversible x) BOOST_NOEXCEPT;
55     //  Returns: x if native endian order is big, otherwise endian_reverse(x)
56   template <class EndianReversible >
57     inline BOOST_CONSTEXPR EndianReversible native_to_big(EndianReversible x) BOOST_NOEXCEPT;
58     //  Returns: x if native endian order is big, otherwise endian_reverse(x)
59 
60   //  reverse byte order unless native endianness is little
61   template <class EndianReversible >
62     inline BOOST_CONSTEXPR EndianReversible little_to_native(EndianReversible x) BOOST_NOEXCEPT;
63     //  Returns: x if native endian order is little, otherwise endian_reverse(x)
64   template <class EndianReversible >
65     inline BOOST_CONSTEXPR EndianReversible native_to_little(EndianReversible x) BOOST_NOEXCEPT;
66     //  Returns: x if native endian order is little, otherwise endian_reverse(x)
67 
68   //  generic conditional reverse byte order
69   template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To,
70     class EndianReversible>
71       inline BOOST_CONSTEXPR EndianReversible conditional_reverse(EndianReversible from) BOOST_NOEXCEPT;
72     //  Returns: If From == To have different values, from.
73     //           Otherwise endian_reverse(from).
74     //  Remarks: The From == To test, and as a consequence which form the return takes, is
75     //           is determined at compile time.
76 
77   //  runtime conditional reverse byte order
78   template <class EndianReversible >
79     inline BOOST_CONSTEXPR EndianReversible conditional_reverse(EndianReversible from,
80       BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order)
81         BOOST_NOEXCEPT;
82       //  Returns: from_order == to_order ? from : endian_reverse(from).
83 
84   //------------------------------------------------------------------------------------//
85 
86 
87   //  Q: What happened to bswap, htobe, and the other synonym functions based on names
88   //     popularized by BSD, OS X, and Linux?
89   //  A: Turned out these may be implemented as macros on some systems. Ditto POSIX names
90   //     for such functionality. Since macros would cause endless problems with functions
91   //     of the same names, and these functions are just synonyms anyhow, they have been
92   //     removed.
93 
94 
95   //------------------------------------------------------------------------------------//
96   //                                                                                    //
97   //                            reverse in place interfaces                             //
98   //                                                                                    //
99   //                             user-defined types (UDTs)                              //
100   //                                                                                    //
101   //  All reverse in place function templates are required to be implemented in terms   //
102   //  of an unqualified call to "endian_reverse_inplace(x)", a function reversing       //
103   //  the endianness of x, which is a non-const reference. This provides a              //
104   //  customization point for any UDT that provides a "reverse_inplace" free-function   //
105   //  meeting the requirements. The free-function must be declared in the same          //
106   //  namespace as the UDT itself so that it will be found by argument-dependent        //
107   //   lookup (ADL).                                                                    //
108   //                                                                                    //
109   //------------------------------------------------------------------------------------//
110 
111   //  reverse in place
112   //  in detail/endian_reverse.hpp
113   template <class EndianReversible>
114     inline void endian_reverse_inplace(EndianReversible& x) BOOST_NOEXCEPT;
115     //  Effects: x = endian_reverse(x)
116 
117   //  reverse in place unless native endianness is big
118   template <class EndianReversibleInplace>
119     inline void big_to_native_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
120     //  Effects: none if native byte-order is big, otherwise endian_reverse_inplace(x)
121   template <class EndianReversibleInplace>
122     inline void native_to_big_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
123     //  Effects: none if native byte-order is big, otherwise endian_reverse_inplace(x)
124 
125   //  reverse in place unless native endianness is little
126   template <class EndianReversibleInplace>
127     inline void little_to_native_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
128     //  Effects: none if native byte-order is little, otherwise endian_reverse_inplace(x);
129   template <class EndianReversibleInplace>
130     inline void native_to_little_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
131     //  Effects: none if native byte-order is little, otherwise endian_reverse_inplace(x);
132 
133   //  generic conditional reverse in place
134   template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To,
135     class EndianReversibleInplace>
136   inline void conditional_reverse_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
137 
138   //  runtime reverse in place
139   template <class EndianReversibleInplace>
140   inline void conditional_reverse_inplace(EndianReversibleInplace& x,
141     BOOST_SCOPED_ENUM(order) from_order,  BOOST_SCOPED_ENUM(order) to_order)
142     BOOST_NOEXCEPT;
143 
144 //----------------------------------- end synopsis -------------------------------------//
145 
146 namespace detail
147 {
148 
149 template<class T> struct is_endian_reversible: boost::integral_constant<bool,
150     boost::is_class<T>::value || ( boost::is_integral<T>::value && !boost::is_same<T, bool>::value )>
151 {
152 };
153 
154 } // namespace detail
155 
156 template <class EndianReversible>
big_to_native(EndianReversible x)157 inline BOOST_CONSTEXPR EndianReversible big_to_native( EndianReversible x ) BOOST_NOEXCEPT
158 {
159     BOOST_STATIC_ASSERT( detail::is_endian_reversible<EndianReversible>::value );
160 
161 #if BOOST_ENDIAN_BIG_BYTE
162 
163     return x;
164 
165 #else
166 
167     return endian_reverse(x);
168 
169 #endif
170   }
171 
172 template <class EndianReversible>
native_to_big(EndianReversible x)173 inline BOOST_CONSTEXPR EndianReversible native_to_big( EndianReversible x ) BOOST_NOEXCEPT
174 {
175     BOOST_STATIC_ASSERT( detail::is_endian_reversible<EndianReversible>::value );
176 
177 #if BOOST_ENDIAN_BIG_BYTE
178 
179     return x;
180 
181 #else
182 
183     return endian_reverse(x);
184 
185 #endif
186 }
187 
188 template <class EndianReversible>
little_to_native(EndianReversible x)189 inline BOOST_CONSTEXPR EndianReversible little_to_native( EndianReversible x ) BOOST_NOEXCEPT
190 {
191     BOOST_STATIC_ASSERT( detail::is_endian_reversible<EndianReversible>::value );
192 
193 #if BOOST_ENDIAN_LITTLE_BYTE
194 
195     return x;
196 
197 #else
198 
199     return endian_reverse(x);
200 
201 #endif
202 }
203 
204 template <class EndianReversible>
native_to_little(EndianReversible x)205 inline BOOST_CONSTEXPR EndianReversible native_to_little( EndianReversible x ) BOOST_NOEXCEPT
206 {
207     BOOST_STATIC_ASSERT( detail::is_endian_reversible<EndianReversible>::value );
208 
209 #if BOOST_ENDIAN_LITTLE_BYTE
210 
211     return x;
212 
213 #else
214 
215     return endian_reverse(x);
216 
217 #endif
218 }
219 
220 namespace detail
221 {
222 
223 template<class EndianReversible>
conditional_reverse_impl(EndianReversible x,boost::true_type)224 inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, boost::true_type ) BOOST_NOEXCEPT
225 {
226     return x;
227 }
228 
229 template<class EndianReversible>
conditional_reverse_impl(EndianReversible x,boost::false_type)230 inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, boost::false_type ) BOOST_NOEXCEPT
231 {
232     return endian_reverse( x );
233 }
234 
235 } // namespace detail
236 
237 // generic conditional reverse
238 template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversible>
conditional_reverse(EndianReversible x)239 inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x ) BOOST_NOEXCEPT
240 {
241     BOOST_STATIC_ASSERT( detail::is_endian_reversible<EndianReversible>::value );
242     return detail::conditional_reverse_impl( x, boost::integral_constant<bool, From == To>() );
243 }
244 
245 // runtime conditional reverse
246 template <class EndianReversible>
conditional_reverse(EndianReversible x,BOOST_SCOPED_ENUM (order)from_order,BOOST_SCOPED_ENUM (order)to_order)247 inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x,
248     BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order ) BOOST_NOEXCEPT
249 {
250     BOOST_STATIC_ASSERT( detail::is_endian_reversible<EndianReversible>::value );
251     return from_order == to_order? x: endian_reverse( x );
252 }
253 
254 //--------------------------------------------------------------------------------------//
255 //                           reverse-in-place implementation                            //
256 //--------------------------------------------------------------------------------------//
257 
258 namespace detail
259 {
260 
261 template<class T> struct is_endian_reversible_inplace: boost::integral_constant<bool,
262     boost::is_class<T>::value || ( boost::is_integral<T>::value && !boost::is_same<T, bool>::value )>
263 {
264 };
265 
266 } // namespace detail
267 
268 #if BOOST_ENDIAN_BIG_BYTE
269 
270 template <class EndianReversibleInplace>
big_to_native_inplace(EndianReversibleInplace &)271 inline void big_to_native_inplace( EndianReversibleInplace& ) BOOST_NOEXCEPT
272 {
273     BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
274 }
275 
276 #else
277 
278 template <class EndianReversibleInplace>
big_to_native_inplace(EndianReversibleInplace & x)279 inline void big_to_native_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
280 {
281     BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
282     endian_reverse_inplace( x );
283 }
284 
285 #endif
286 
287 #if BOOST_ENDIAN_BIG_BYTE
288 
289 template <class EndianReversibleInplace>
native_to_big_inplace(EndianReversibleInplace &)290 inline void native_to_big_inplace( EndianReversibleInplace& ) BOOST_NOEXCEPT
291 {
292     BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
293 }
294 
295 #else
296 
297 template <class EndianReversibleInplace>
native_to_big_inplace(EndianReversibleInplace & x)298 inline void native_to_big_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
299 {
300     BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
301     endian_reverse_inplace( x );
302 }
303 
304 #endif
305 
306 #if BOOST_ENDIAN_LITTLE_BYTE
307 
308 template <class EndianReversibleInplace>
little_to_native_inplace(EndianReversibleInplace &)309 inline void little_to_native_inplace( EndianReversibleInplace& ) BOOST_NOEXCEPT
310 {
311     BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
312 }
313 
314 #else
315 
316 template <class EndianReversibleInplace>
little_to_native_inplace(EndianReversibleInplace & x)317 inline void little_to_native_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
318 {
319     BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
320     endian_reverse_inplace( x );
321 }
322 
323 #endif
324 
325 #if BOOST_ENDIAN_LITTLE_BYTE
326 
327 template <class EndianReversibleInplace>
native_to_little_inplace(EndianReversibleInplace &)328 inline void native_to_little_inplace( EndianReversibleInplace& ) BOOST_NOEXCEPT
329 {
330     BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
331 }
332 
333 #else
334 
335 template <class EndianReversibleInplace>
native_to_little_inplace(EndianReversibleInplace & x)336 inline void native_to_little_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
337 {
338     BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
339     endian_reverse_inplace( x );
340 }
341 
342 #endif
343 
344 namespace detail
345 {
346 
347 template<class EndianReversibleInplace>
conditional_reverse_inplace_impl(EndianReversibleInplace &,boost::true_type)348 inline void conditional_reverse_inplace_impl( EndianReversibleInplace&, boost::true_type ) BOOST_NOEXCEPT
349 {
350 }
351 
352 template<class EndianReversibleInplace>
conditional_reverse_inplace_impl(EndianReversibleInplace & x,boost::false_type)353 inline void conditional_reverse_inplace_impl( EndianReversibleInplace& x, boost::false_type ) BOOST_NOEXCEPT
354 {
355     endian_reverse_inplace( x );
356 }
357 
358 }  // namespace detail
359 
360 // generic conditional reverse in place
361 template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversibleInplace>
conditional_reverse_inplace(EndianReversibleInplace & x)362 inline void conditional_reverse_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
363 {
364     BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
365     detail::conditional_reverse_inplace_impl( x, boost::integral_constant<bool, From == To>() );
366 }
367 
368 // runtime reverse in place
369 template <class EndianReversibleInplace>
conditional_reverse_inplace(EndianReversibleInplace & x,BOOST_SCOPED_ENUM (order)from_order,BOOST_SCOPED_ENUM (order)to_order)370 inline void conditional_reverse_inplace( EndianReversibleInplace& x,
371     BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order ) BOOST_NOEXCEPT
372 {
373     BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
374 
375     if( from_order != to_order )
376     {
377         endian_reverse_inplace( x );
378     }
379 }
380 
381 // load/store convenience functions
382 
383 // load 16
384 
load_little_s16(unsigned char const * p)385 inline boost::int16_t load_little_s16( unsigned char const * p ) BOOST_NOEXCEPT
386 {
387     return boost::endian::endian_load<boost::int16_t, 2, order::little>( p );
388 }
389 
load_little_u16(unsigned char const * p)390 inline boost::uint16_t load_little_u16( unsigned char const * p ) BOOST_NOEXCEPT
391 {
392     return boost::endian::endian_load<boost::uint16_t, 2, order::little>( p );
393 }
394 
load_big_s16(unsigned char const * p)395 inline boost::int16_t load_big_s16( unsigned char const * p ) BOOST_NOEXCEPT
396 {
397     return boost::endian::endian_load<boost::int16_t, 2, order::big>( p );
398 }
399 
load_big_u16(unsigned char const * p)400 inline boost::uint16_t load_big_u16( unsigned char const * p ) BOOST_NOEXCEPT
401 {
402     return boost::endian::endian_load<boost::uint16_t, 2, order::big>( p );
403 }
404 
405 // load 24
406 
load_little_s24(unsigned char const * p)407 inline boost::int32_t load_little_s24( unsigned char const * p ) BOOST_NOEXCEPT
408 {
409     return boost::endian::endian_load<boost::int32_t, 3, order::little>( p );
410 }
411 
load_little_u24(unsigned char const * p)412 inline boost::uint32_t load_little_u24( unsigned char const * p ) BOOST_NOEXCEPT
413 {
414     return boost::endian::endian_load<boost::uint32_t, 3, order::little>( p );
415 }
416 
load_big_s24(unsigned char const * p)417 inline boost::int32_t load_big_s24( unsigned char const * p ) BOOST_NOEXCEPT
418 {
419     return boost::endian::endian_load<boost::int32_t, 3, order::big>( p );
420 }
421 
load_big_u24(unsigned char const * p)422 inline boost::uint32_t load_big_u24( unsigned char const * p ) BOOST_NOEXCEPT
423 {
424     return boost::endian::endian_load<boost::uint32_t, 3, order::big>( p );
425 }
426 
427 // load 32
428 
load_little_s32(unsigned char const * p)429 inline boost::int32_t load_little_s32( unsigned char const * p ) BOOST_NOEXCEPT
430 {
431     return boost::endian::endian_load<boost::int32_t, 4, order::little>( p );
432 }
433 
load_little_u32(unsigned char const * p)434 inline boost::uint32_t load_little_u32( unsigned char const * p ) BOOST_NOEXCEPT
435 {
436     return boost::endian::endian_load<boost::uint32_t, 4, order::little>( p );
437 }
438 
load_big_s32(unsigned char const * p)439 inline boost::int32_t load_big_s32( unsigned char const * p ) BOOST_NOEXCEPT
440 {
441     return boost::endian::endian_load<boost::int32_t, 4, order::big>( p );
442 }
443 
load_big_u32(unsigned char const * p)444 inline boost::uint32_t load_big_u32( unsigned char const * p ) BOOST_NOEXCEPT
445 {
446     return boost::endian::endian_load<boost::uint32_t, 4, order::big>( p );
447 }
448 
449 // load 40
450 
load_little_s40(unsigned char const * p)451 inline boost::int64_t load_little_s40( unsigned char const * p ) BOOST_NOEXCEPT
452 {
453     return boost::endian::endian_load<boost::int64_t, 5, order::little>( p );
454 }
455 
load_little_u40(unsigned char const * p)456 inline boost::uint64_t load_little_u40( unsigned char const * p ) BOOST_NOEXCEPT
457 {
458     return boost::endian::endian_load<boost::uint64_t, 5, order::little>( p );
459 }
460 
load_big_s40(unsigned char const * p)461 inline boost::int64_t load_big_s40( unsigned char const * p ) BOOST_NOEXCEPT
462 {
463     return boost::endian::endian_load<boost::int64_t, 5, order::big>( p );
464 }
465 
load_big_u40(unsigned char const * p)466 inline boost::uint64_t load_big_u40( unsigned char const * p ) BOOST_NOEXCEPT
467 {
468     return boost::endian::endian_load<boost::uint64_t, 5, order::big>( p );
469 }
470 
471 // load 48
472 
load_little_s48(unsigned char const * p)473 inline boost::int64_t load_little_s48( unsigned char const * p ) BOOST_NOEXCEPT
474 {
475     return boost::endian::endian_load<boost::int64_t, 6, order::little>( p );
476 }
477 
load_little_u48(unsigned char const * p)478 inline boost::uint64_t load_little_u48( unsigned char const * p ) BOOST_NOEXCEPT
479 {
480     return boost::endian::endian_load<boost::uint64_t, 6, order::little>( p );
481 }
482 
load_big_s48(unsigned char const * p)483 inline boost::int64_t load_big_s48( unsigned char const * p ) BOOST_NOEXCEPT
484 {
485     return boost::endian::endian_load<boost::int64_t, 6, order::big>( p );
486 }
487 
load_big_u48(unsigned char const * p)488 inline boost::uint64_t load_big_u48( unsigned char const * p ) BOOST_NOEXCEPT
489 {
490     return boost::endian::endian_load<boost::uint64_t, 6, order::big>( p );
491 }
492 
493 // load 56
494 
load_little_s56(unsigned char const * p)495 inline boost::int64_t load_little_s56( unsigned char const * p ) BOOST_NOEXCEPT
496 {
497     return boost::endian::endian_load<boost::int64_t, 7, order::little>( p );
498 }
499 
load_little_u56(unsigned char const * p)500 inline boost::uint64_t load_little_u56( unsigned char const * p ) BOOST_NOEXCEPT
501 {
502     return boost::endian::endian_load<boost::uint64_t, 7, order::little>( p );
503 }
504 
load_big_s56(unsigned char const * p)505 inline boost::int64_t load_big_s56( unsigned char const * p ) BOOST_NOEXCEPT
506 {
507     return boost::endian::endian_load<boost::int64_t, 7, order::big>( p );
508 }
509 
load_big_u56(unsigned char const * p)510 inline boost::uint64_t load_big_u56( unsigned char const * p ) BOOST_NOEXCEPT
511 {
512     return boost::endian::endian_load<boost::uint64_t, 7, order::big>( p );
513 }
514 
515 // load 64
516 
load_little_s64(unsigned char const * p)517 inline boost::int64_t load_little_s64( unsigned char const * p ) BOOST_NOEXCEPT
518 {
519     return boost::endian::endian_load<boost::int64_t, 8, order::little>( p );
520 }
521 
load_little_u64(unsigned char const * p)522 inline boost::uint64_t load_little_u64( unsigned char const * p ) BOOST_NOEXCEPT
523 {
524     return boost::endian::endian_load<boost::uint64_t, 8, order::little>( p );
525 }
526 
load_big_s64(unsigned char const * p)527 inline boost::int64_t load_big_s64( unsigned char const * p ) BOOST_NOEXCEPT
528 {
529     return boost::endian::endian_load<boost::int64_t, 8, order::big>( p );
530 }
531 
load_big_u64(unsigned char const * p)532 inline boost::uint64_t load_big_u64( unsigned char const * p ) BOOST_NOEXCEPT
533 {
534     return boost::endian::endian_load<boost::uint64_t, 8, order::big>( p );
535 }
536 
537 // store 16
538 
store_little_s16(unsigned char * p,boost::int16_t v)539 inline void store_little_s16( unsigned char * p, boost::int16_t v )
540 {
541     boost::endian::endian_store<boost::int16_t, 2, order::little>( p, v );
542 }
543 
store_little_u16(unsigned char * p,boost::uint16_t v)544 inline void store_little_u16( unsigned char * p, boost::uint16_t v )
545 {
546     boost::endian::endian_store<boost::uint16_t, 2, order::little>( p, v );
547 }
548 
store_big_s16(unsigned char * p,boost::int16_t v)549 inline void store_big_s16( unsigned char * p, boost::int16_t v )
550 {
551     boost::endian::endian_store<boost::int16_t, 2, order::big>( p, v );
552 }
553 
store_big_u16(unsigned char * p,boost::uint16_t v)554 inline void store_big_u16( unsigned char * p, boost::uint16_t v )
555 {
556     boost::endian::endian_store<boost::uint16_t, 2, order::big>( p, v );
557 }
558 
559 // store 24
560 
store_little_s24(unsigned char * p,boost::int32_t v)561 inline void store_little_s24( unsigned char * p, boost::int32_t v )
562 {
563     boost::endian::endian_store<boost::int32_t, 3, order::little>( p, v );
564 }
565 
store_little_u24(unsigned char * p,boost::uint32_t v)566 inline void store_little_u24( unsigned char * p, boost::uint32_t v )
567 {
568     boost::endian::endian_store<boost::uint32_t, 3, order::little>( p, v );
569 }
570 
store_big_s24(unsigned char * p,boost::int32_t v)571 inline void store_big_s24( unsigned char * p, boost::int32_t v )
572 {
573     boost::endian::endian_store<boost::int32_t, 3, order::big>( p, v );
574 }
575 
store_big_u24(unsigned char * p,boost::uint32_t v)576 inline void store_big_u24( unsigned char * p, boost::uint32_t v )
577 {
578     boost::endian::endian_store<boost::uint32_t, 3, order::big>( p, v );
579 }
580 
581 // store 32
582 
store_little_s32(unsigned char * p,boost::int32_t v)583 inline void store_little_s32( unsigned char * p, boost::int32_t v )
584 {
585     boost::endian::endian_store<boost::int32_t, 4, order::little>( p, v );
586 }
587 
store_little_u32(unsigned char * p,boost::uint32_t v)588 inline void store_little_u32( unsigned char * p, boost::uint32_t v )
589 {
590     boost::endian::endian_store<boost::uint32_t, 4, order::little>( p, v );
591 }
592 
store_big_s32(unsigned char * p,boost::int32_t v)593 inline void store_big_s32( unsigned char * p, boost::int32_t v )
594 {
595     boost::endian::endian_store<boost::int32_t, 4, order::big>( p, v );
596 }
597 
store_big_u32(unsigned char * p,boost::uint32_t v)598 inline void store_big_u32( unsigned char * p, boost::uint32_t v )
599 {
600     boost::endian::endian_store<boost::uint32_t, 4, order::big>( p, v );
601 }
602 
603 // store 40
604 
store_little_s40(unsigned char * p,boost::int64_t v)605 inline void store_little_s40( unsigned char * p, boost::int64_t v )
606 {
607     boost::endian::endian_store<boost::int64_t, 5, order::little>( p, v );
608 }
609 
store_little_u40(unsigned char * p,boost::uint64_t v)610 inline void store_little_u40( unsigned char * p, boost::uint64_t v )
611 {
612     boost::endian::endian_store<boost::uint64_t, 5, order::little>( p, v );
613 }
614 
store_big_s40(unsigned char * p,boost::int64_t v)615 inline void store_big_s40( unsigned char * p, boost::int64_t v )
616 {
617     boost::endian::endian_store<boost::int64_t, 5, order::big>( p, v );
618 }
619 
store_big_u40(unsigned char * p,boost::uint64_t v)620 inline void store_big_u40( unsigned char * p, boost::uint64_t v )
621 {
622     boost::endian::endian_store<boost::uint64_t, 5, order::big>( p, v );
623 }
624 
625 // store 48
626 
store_little_s48(unsigned char * p,boost::int64_t v)627 inline void store_little_s48( unsigned char * p, boost::int64_t v )
628 {
629     boost::endian::endian_store<boost::int64_t, 6, order::little>( p, v );
630 }
631 
store_little_u48(unsigned char * p,boost::uint64_t v)632 inline void store_little_u48( unsigned char * p, boost::uint64_t v )
633 {
634     boost::endian::endian_store<boost::uint64_t, 6, order::little>( p, v );
635 }
636 
store_big_s48(unsigned char * p,boost::int64_t v)637 inline void store_big_s48( unsigned char * p, boost::int64_t v )
638 {
639     boost::endian::endian_store<boost::int64_t, 6, order::big>( p, v );
640 }
641 
store_big_u48(unsigned char * p,boost::uint64_t v)642 inline void store_big_u48( unsigned char * p, boost::uint64_t v )
643 {
644     boost::endian::endian_store<boost::uint64_t, 6, order::big>( p, v );
645 }
646 
647 // store 56
648 
store_little_s56(unsigned char * p,boost::int64_t v)649 inline void store_little_s56( unsigned char * p, boost::int64_t v )
650 {
651     boost::endian::endian_store<boost::int64_t, 7, order::little>( p, v );
652 }
653 
store_little_u56(unsigned char * p,boost::uint64_t v)654 inline void store_little_u56( unsigned char * p, boost::uint64_t v )
655 {
656     boost::endian::endian_store<boost::uint64_t, 7, order::little>( p, v );
657 }
658 
store_big_s56(unsigned char * p,boost::int64_t v)659 inline void store_big_s56( unsigned char * p, boost::int64_t v )
660 {
661     boost::endian::endian_store<boost::int64_t, 7, order::big>( p, v );
662 }
663 
store_big_u56(unsigned char * p,boost::uint64_t v)664 inline void store_big_u56( unsigned char * p, boost::uint64_t v )
665 {
666     boost::endian::endian_store<boost::uint64_t, 7, order::big>( p, v );
667 }
668 
669 // store 64
670 
store_little_s64(unsigned char * p,boost::int64_t v)671 inline void store_little_s64( unsigned char * p, boost::int64_t v )
672 {
673     boost::endian::endian_store<boost::int64_t, 8, order::little>( p, v );
674 }
675 
store_little_u64(unsigned char * p,boost::uint64_t v)676 inline void store_little_u64( unsigned char * p, boost::uint64_t v )
677 {
678     boost::endian::endian_store<boost::uint64_t, 8, order::little>( p, v );
679 }
680 
store_big_s64(unsigned char * p,boost::int64_t v)681 inline void store_big_s64( unsigned char * p, boost::int64_t v )
682 {
683     boost::endian::endian_store<boost::int64_t, 8, order::big>( p, v );
684 }
685 
store_big_u64(unsigned char * p,boost::uint64_t v)686 inline void store_big_u64( unsigned char * p, boost::uint64_t v )
687 {
688     boost::endian::endian_store<boost::uint64_t, 8, order::big>( p, v );
689 }
690 
691 }  // namespace endian
692 }  // namespace boost
693 
694 #endif // BOOST_ENDIAN_CONVERSION_HPP
695