Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2008-07-26 17:27:29

I need help with fixing code in BOOST_ROOT/libs/integer/test/
integer_test.cpp. It works fine on my computer, but other ones are
giving errors. I have some guesses on what's wrong, but I need
suggestions on what the fixes should be.

1. I have a custom meta-function like:

typedef boost::mpl::vector<unsigned char, unsigned short, unsigned
int, unsigned long long> distinct_unsigned_types;

typedef boost::mpl::transform<
     boost::make_signed< boost::mpl::_1 >
>::type distinct_signed_types;

// List the digit counts for each integral type
template < typename T >
struct digits_of
     : boost::mpl::int_< std::numeric_limits<T>::digits >

typedef boost::mpl::transform<
     digits_of< boost::mpl::_1 >
>::type distinct_integral_bit_counts;

I noticed that supplied meta-functions, like boost.make_unsigned, use
macros in their implementations, instead of the straight
implementation I use in digits_of. Now MPL says that its machinery
will make sure that straight implementations work. However, I don't
think it's successful on deficient compilers. Maybe I should
structure digits_of with all the work-around macros. How? (I don't
want to just look at the headers and guess how they work.)

2. I don't think I have SFINAE selection correct:

template < typename ValueT, template<ValueT> class Tmpl, ValueT Value >
print_out_template( Tmpl<Value> const &, ValueT setting, char const
  *template_pre_name, char const *template_post_name, typename
  *unused = 0 )
     // Too bad the type-id expression couldn't use the compact form
     // but type-ids of dereferenced null pointers throw by order of C
++ 2003,
     // sect. 5.2.8, para. 2 (although the result is not conceptually
     PRIVATE_SHOW_MESSAGE( "This is " << template_pre_name << setting
      << template_post_name << " specialization, with type '" <<
      Tmpl<Value>::type).name() << "'." );
     return true;

template < typename ValueT, typename T >
print_out_template( T const &, ValueT setting, char const
  char const *template_post_name )
     PRIVATE_SHOW_MESSAGE( "Looking for " << template_pre_name <<
      << template_post_name << " specialization? It doesn't exist." );
     return false;
#error "These tests cannot work without Substitution-Failure-Is-Not-

The BOOST_NO_SFINAE guards didn't help, compilers still choked on
this code. (I guess I'll remove those guards later.) I think that
any type that doesn't have an inner "type" will only choose the false-
return case. On my computer, types with an inner "type" will choose
the true return case, with that case being given priority. The
reports are giving errors where, when given a type with an inner
"type", the two cases are considered equal, leading to an ambiguity
error. How do I restructure this code?

Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT hotmail DOT com

Boost list run by bdawes at, gregod at, cpdaniel at, john at