[C++-sig] Re: Mac OS 10 & type_with_alignment.hpp

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Mon May 26 18:45:25 CEST 2003


--- David Abrahams <dave at boost-consulting.com> wrote:
> OK, please undo my suggested patch, and feel free to disable those
> asserts on MacOSX :(

Okey Dokey. According to this message:

http://mail-index.netbsd.org/port-powerpc/1999/12/29/0001.html

"PowerPC implementations operating in big-endian mode do not require strict
alignment." (Python sys.byteorder reports 'big'.)

Maybe that's the reason why the alignment calculator "fails?" If gcc doesn't
align anything anyway what else can one expect?

This leads me to suggest a relatively unspecific patch:

Index: type_with_alignment.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/type_traits/type_with_alignment.hpp,v
retrieving revision 1.10
diff -u -r1.10 type_with_alignment.hpp
--- type_with_alignment.hpp     16 Apr 2003 13:36:07 -0000      1.10
+++ type_with_alignment.hpp     26 May 2003 05:47:03 -0000
@@ -110,8 +110,10 @@
 
     BOOST_STATIC_CONSTANT(std::size_t, found = alignment_of<align_t>::value);
 
+#if !(defined(__APPLE__) && defined(__MACH__) && defined(__GNUC__))
     BOOST_STATIC_ASSERT(found >= Align);
     BOOST_STATIC_ASSERT(found % Align == 0);
+#endif
 
  public:
     typedef align_t type;


However, this raises the question "why do we need all the metaprogramming
overhead if the result is meaningless anyway?" Here is a more radical
suggestion:

Index: type_with_alignment.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/type_traits/type_with_alignment.hpp,v
retrieving revision 1.10
diff -u -r1.10 type_with_alignment.hpp
--- type_with_alignment.hpp     16 Apr 2003 13:36:07 -0000      1.10
+++ type_with_alignment.hpp     26 May 2003 16:38:11 -0000
@@ -96,6 +96,14 @@
 
 } // namespace detail

+#if defined(__APPLE__) && defined(__MACH__) && defined(__GNUC__)
+template <int Align>
+class type_with_alignment
+{
+  public:
+    typedef char type;
+};
+#else
 // This alignment method originally due to Brian Parker, implemented by David
 // Abrahams, and then ported here by Doug Gregor.
 template <int Align>
@@ -116,6 +124,7 @@
  public:
     typedef align_t type;
 };
+#endif

 #else


Both solutions work. Thoughts?

Ralf


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com




More information about the Cplusplus-sig mailing list