
From what I understand, this means that I am relying on implementation
Hi there, I'd like to make sure that some of my classes are only used with particular value types. This is easy enough to implement for integers, using BOOST_CONCEPT_ASSERT((boost::Integer<T>)) . However, there is no boost::FloatingPoint<T>, which is a bit odd. The following, easy code seems to do what I want, but reqires inclusion of boost/concept/detail/concept_def.hpp /*****************************************************************/ namespace boost { BOOST_concept(FloatingPoint, (T)) { BOOST_CONCEPT_USAGE(FloatingPoint) { x.error_type_must_be_a_floating_point_type(); } private: T x; }; template <> struct FloatingPoint<long double> {}; template <> struct FloatingPoint<double> {}; template <> struct FloatingPoint<float> {}; } /*****************************************************************/ details with the above code. Is there any way to do the above in a portable way ? Thanks and Best Regards, Ruediger P.S.: If the above seems acceptable, please feel free to include it in Boost.Concept.

On Wed, Sep 15, 2010 at 2:02 PM, Ruediger Berlich
Hi there,
I'd like to make sure that some of my classes are only used with particular value types. This is easy enough to implement for integers, using BOOST_CONCEPT_ASSERT((boost::Integer<T>)) . However, there is no boost::FloatingPoint<T>, which is a bit odd.
The following, easy code seems to do what I want, but reqires inclusion of boost/concept/detail/concept_def.hpp
/*****************************************************************/
namespace boost { BOOST_concept(FloatingPoint, (T))
From what I understand, this means that I am relying on implementation details with the above code.
Yes. Why did you use the undocumente BOOST_concept macro? That only exists for backward compatibility with older uses of the BCCL.
Is there any way to do the above in a portable way?
// untested
#include
P.S.: If the above seems acceptable, please feel free to include it in Boost.Concept.
If what I suggested works out for you, would you mind submitting a patch to Trac? -- Dave Abrahams BoostPro Computing http://www.boostpro.com

Dear Dave, thanks a lot! Dave Abrahams wrote:
On Wed, Sep 15, 2010 at 2:02 PM, Ruediger Berlich [...]
From what I understand, this means that I am relying on implementation details with the above code.
Yes. Why did you use the undocumente BOOST_concept macro? That only exists for backward compatibility with older uses of the BCCL.
This is an almost verbatim copy of the code used for Integer<T>, SignedInteger<T> etc. in $BOOSTROOOT/include/boost/concept_check.hpp .
Is there any way to do the above in a portable way?
// untested #include
#include template <class T> struct FloatingPoint { BOOST_MPL_ASSERT((boost::is_floating<T>)); };
P.S.: If the above seems acceptable, please feel free to include it in Boost.Concept.
If what I suggested works out for you, would you mind submitting a patch to Trac?
The following example, using your suggestion, works for me (g++ 4.4.3 /
Ubuntu 10.04). See further below for comments regarding a patch and trac
item:
//------------------------------------------------------------------------
#include <iostream>
#include
participants (2)
-
Dave Abrahams
-
Ruediger Berlich