
Cromwell Enage writes:
Morning, all.
Hi Cromwell,
I'm trying to implement a compile-time greatest common divisor metafunction,
This one already exists in Boost, although its location is somewhat unexpected; please take a look at math/common_factor library, http://www.boost.org/libs/math/doc/common_factor.html.
a key component of which is boost::mpl::modulus_c. Am I correct if I say that the following is typical usage of this class template?
#include <iostream> #include <boost/mpl/modulus.hpp>
int main() { typedef typename ^^^^^^^^
'typename' is not allowed outside of templates.
boost::mpl::modulus<int,14,6>::type ^^^^^^^
I suppose you meant 'modulus_c', here.
remainder_type;
std::cout << "The remainder of 14 divided by 6 is"; std::cout << remainder_type::value << std::endl;
return 0; }
MinGW 3.2 accepts this usage, but MSVC 7.1 files the following complaint:
..\..\Libraries\boost\boost\mpl\modulus.hpp(39) : error C2975: 'N' : invalid template argument for 'boost::mpl::integral_c', compile-time evaluatable constant expression expected
It seems MSVC doesn't recognize A % B as an integral constant expression.
Hmm, if I make the above fixes, it compiles fine for me. May be the problem disappeared when you reduced the code for the post?
What's the proper way of handling this?
Fixing the library, which I'll happily do if we can reproduce the issue. -- Aleksey Gurtovoy MetaCommunications Engineering