Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62821 - in sandbox/endian_ext/boost: endian integer
From: vicente.botet_at_[hidden]
Date: 2010-06-11 18:49:51


Author: viboes
Date: 2010-06-11 18:49:50 EDT (Fri, 11 Jun 2010)
New Revision: 62821
URL: http://svn.boost.org/trac/boost/changeset/62821

Log:
Bugs fixe
 

Text files modified:
   sandbox/endian_ext/boost/endian/domain_map.hpp | 2
   sandbox/endian_ext/boost/integer/endian_conversion.hpp | 91 ++++++++++++++++++---------------------
   2 files changed, 43 insertions(+), 50 deletions(-)

Modified: sandbox/endian_ext/boost/endian/domain_map.hpp
==============================================================================
--- sandbox/endian_ext/boost/endian/domain_map.hpp (original)
+++ sandbox/endian_ext/boost/endian/domain_map.hpp 2010-06-11 18:49:50 EDT (Fri, 11 Jun 2010)
@@ -47,7 +47,7 @@
         // fundamental types are native
         template <typename Domain, typename T, bool IsSeq>
         struct domain_map_impl<Domain, T, true, IsSeq> {
- typedef native type;
+ typedef Domain type;
         };
 
         // other type which has not been explicitly declared is undefined,

Modified: sandbox/endian_ext/boost/integer/endian_conversion.hpp
==============================================================================
--- sandbox/endian_ext/boost/integer/endian_conversion.hpp (original)
+++ sandbox/endian_ext/boost/integer/endian_conversion.hpp 2010-06-11 18:49:50 EDT (Fri, 11 Jun 2010)
@@ -14,9 +14,7 @@
 #define BOOST_INTEGER_ENDIAN_CONVERT_HPP
 
 #include <boost/endian/endian.hpp>
-//~ #include <boost/endian/shared_tree.hpp>
 #include <boost/endian/domain_map.hpp>
-#include <boost/endian/native_tree.hpp>
 #include <boost/mpl/deref.hpp>
 #include <boost/mpl/next.hpp>
 #include <boost/mpl/begin.hpp>
@@ -33,7 +31,10 @@
 namespace integer {
 
     template <typename EndianTarget, typename EndianSource, typename T>
- void convert_to_from(T& r);
+ inline void convert_to_from(T& r);
+
+ template <typename EndianTarget, typename EndianSource, typename T>
+ inline void convert_to_from_impl(T& r);
 
     namespace integer_detail {
         template <typename EndianTarget, typename EndianSource, typename T,
@@ -42,17 +43,18 @@
>
         struct convert_to_from;
 
- template <typename ItTarget, typename EndTarget, typename ItSource, typename EndSource>
+ template <
+ typename ItTarget, typename EndTarget,
+ typename ItSource, typename EndSource>
         struct convert_to_from_seq_loop {
             template <typename It, typename End>
             static void apply(It& it, End& end) {
- boost::integer::convert_to_from<
+ boost::integer::convert_to_from_impl<
                     typename mpl::deref<ItTarget>::type,
                     typename mpl::deref<ItSource>::type,
- typename remove_reference<typename remove_cv<
- typename fusion::result_of::deref<It>::type
- >::type >::type
- >(fusion::deref(it));
+ typename remove_reference<typename remove_cv<typename fusion::result_of::deref<It>::type>::type >::type
+ >
+ (fusion::deref(it));
                 convert_to_from_seq_loop<
                     typename mpl::next<ItTarget>::type, EndTarget,
                     typename mpl::next<ItSource>::type, EndSource
@@ -61,7 +63,7 @@
         };
 
         template <typename EndTarget, typename EndSource>
- struct convert_to_from_seq_loop<EndTarget,EndTarget,EndSource,EndSource> {
+ struct convert_to_from_seq_loop<EndTarget, EndTarget, EndSource, EndSource> {
             template <typename It, typename End>
             static void apply(It& it, End& end) {
             }
@@ -82,58 +84,73 @@
 
         // same endianess do nothiong
         template <typename E, typename T, bool IsFundamental, bool IsSeq>
- struct convert_to_from<E,E,T,IsFundamental,IsSeq> {
- static void apply(T& r) {}
+ struct convert_to_from<E, E, T, IsFundamental, IsSeq> {
+ static void apply(T& r) {
+ }
         };
 
         template <typename E, typename T>
- struct convert_to_from<E,E,T,false,false> {
- static void apply(T& r) {}
+ struct convert_to_from<E, E, T, false, false> {
+ static void apply(T& r) {
+ }
         };
 
         template <typename E, typename T>
         struct convert_to_from<E,E,T,false,true> {
- static void apply(T& r) {}
+ static void apply(T& r) {
+ }
         };
 
         // on fundamentals apply endian views
         template <typename T>
- struct convert_to_from<endian::big,endian::little, T,true,false> {
+ struct convert_to_from<boost::endian::big, boost::endian::little, T, true, false> {
             static void apply(T& r) {
                 as_big(r)=as_little(r);
             }
         };
         // on fundamentals apply endian views
         template <typename T>
- struct convert_to_from<endian::little,endian::big, T, true,false> {
+ struct convert_to_from<boost::endian::little, boost::endian::big, T, true, false> {
             static void apply(T& r) {
                 as_little(r)=as_big(r);
             }
         };
         template <typename EndianTarget, typename EndianSource, typename T>
- struct convert_to_from<EndianTarget,EndianSource, T, false,true>
+ struct convert_to_from<EndianTarget, EndianSource, T, false, true>
         : convert_to_from_seq<EndianTarget,EndianSource,T> {};
 
         template <typename EndianTarget, typename EndianSource, typename T>
- struct convert_to_from<EndianTarget,EndianSource, T, false,false> {
- static void apply(T& r) {}
+ struct convert_to_from<EndianTarget, EndianSource, T, false, false> {
+ static void apply(T& r) {
+ }
             //~ template <typename T>
             //~ static void apply(T& r) {
                 //~ //use ADL to find this
- //~ convert_to_from_impl<EndianTarget,EndianSource>(r);
+ //~ convert_to_from_impl<EndianTarget,EndianSource,T>(r);
             //~ }
         };
 
     } // namespace integer_detail
 
 template <typename EndianTarget, typename EndianSource, typename T>
-void convert_to_from(T& r) {
+inline void convert_to_from_impl(T& r) {
+ integer_detail::convert_to_from<
+ EndianTarget,
+ EndianSource,
+ T
+ >::apply(r);
+}
+
+template <typename EndianTarget, typename EndianSource, typename T>
+inline void convert_to_from(T& r) {
     integer_detail::convert_to_from<
             typename boost::endian::domain_map<EndianTarget,T>::type,
             typename boost::endian::domain_map<EndianSource,T>::type,
- T>::apply(r);
+ T
+ >::apply(r);
 }
 
+
 //~ template <typename EndianTarget, typename EndianSource, typename T, typename N>
 //~ void convert_to_from(T[N] a) {
     //~ for (unsigned int i=0; i<N; ++i) {
@@ -144,7 +161,7 @@
 template <typename EndianSource, typename T>
 void convert_from(T& r) {
     integer_detail::convert_to_from<
- typename endian::native_tree<T>::type,
+ typename boost::endian::domain_map<boost::endian::native,T>::type,
         typename boost::endian::domain_map<EndianSource,T>::type,
         T>::apply(r);
 }
@@ -153,34 +170,10 @@
 void convert_to(T& r) {
     integer_detail::convert_to_from<
         typename boost::endian::domain_map<EndianTarget,T>::type,
- typename endian::native_tree<T>::type,
+ typename boost::endian::domain_map<boost::endian::native, T>::type,
         T>::apply(r);
 }
 
-#if 0
-template <typename EndianTarget, typename EndianSource, typename T>
-void convert_to_from(T& r) {
- integer_detail::convert_to_from<EndianTarget, EndianSource, T>::apply(r);
-}
-
-//~ template <typename EndianTarget, typename EndianSource, typename T, typename N>
-//~ void convert_to_from(T[N] a) {
- //~ for (unsigned int i=0; i<N; ++i) {
- //~ convert_to_from<EndianTarget, EndianSource, T>(a[i]);
- //~ }
-//~ }
-
-template <typename EndianSource, typename T>
-void convert_from(T& r) {
- integer_detail::convert_to_from<typename endian::native_tree<T>::type, EndianSource, T>::apply(r);
-}
-
-template <typename EndianTarget, typename T>
-void convert_to(T& r) {
- integer_detail::convert_to_from<EndianTarget, typename endian::native_tree<T>::type, T>::apply(r);
-}
-#endif
-
 } // namespace integer
 } // namespace boost
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk