|
Boost Users : |
Subject: [Boost-users] [Concept] boost::FloatingPoint<T>
From: Ruediger Berlich (ruediger.berlich_at_[hidden])
Date: 2010-09-15 14:02:49
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> {};
}
/*****************************************************************/
>From what I understand, this means that I am relying on implementation
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.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net