ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> boost
boost
Re: [boost] Mac OS 10 & type_traits/type_with_alignment.hpp
by Ralf W. Grosse-Kunstleve other posts by this author
Jun 7 2003 12:50PM messages near this date
Re: [boost] Mac OS 10 & type_traits/type_with_alignment.hpp | Re: [boost] Mac OS 10 & type_traits/type_with_alignment.hpp
--- Douglas Gregor <gregod@[...].edu>  wrote:

Hi Doug,

>  If you could figure out what alignment value you're trying to get a type for
>  it would help greatly. One way you could do it would be to replace the
>  static assertion lines with something that will halt the compile and give
>  back the Align value in an error message, e.g.,

Thanks a lot for your message!

>  // somewhere
>  template<bool DontPrintIt, std::size_t Align> struct maybe_print_align {
>  typedef void type; }
>  template<std::size_t Align> struct maybe_print_align<false, Align> {};
>  
>  // instead of the static asserts:
>  typedef typename maybe_print_align<(found >= Align), Align>::type foobar;
>  
>  Note that when those static asserts fail, it means that you aren't getting
>  back a type with the right alignment.

That's a cool trick and it works great. I've expanded your templates
to also print the value of the "found" constant:

template<bool DontPrintIt, std::size_t Align, std::size_t Found>  struct
maybe_print_align { typedef void type; };
template<std::size_t Align, std::size_t Found>  struct maybe_print_align<false,
Align, Found>  {};

typedef typename maybe_print_align<(found > = Align), Align, found>::type
foobar;

Here is the error:

/var/tmp/mac/boost/boost/type_traits/type_with_alignment.hpp:120:
error: no type named `type' in `boost::maybe_print_align<false, 8, 4> '

The full error message is here:

http://cci.lbl.gov/~rwgk/tmp/mac_os_10_alignment_problem

FYI: In the meantime we've found out that the PowerPC doesn't have
strict alignment requirements (but unaligned access may be associated
with performance penalties). After a discussion with David Abrahams
I've disabled the static assertions in type_with_alignment.hpp:

#if !(defined(__APPLE__) && defined(__MACH__) && defined(__GNUC__))
    BOOST_STATIC_ASSERT(found > = Align);
    BOOST_STATIC_ASSERT(found % Align == 0);
#endif

Ralf


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Ralf W. Grosse-Kunstleve
Douglas Gregor
Ralf W. Grosse-Kunstleve
Douglas Gregor
Ralf W. Grosse-Kunstleve
David Abrahams
Douglas Paul Gregor
Douglas Paul Gregor
Ralf W. Grosse-Kunstleve

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved