Hi Robert,
look at static_warning.hpp
My documentation was saying: todo !!!!
But I checked the web and found discussion and this lead me to create
something useful for me.
So I'm sending the info for people interested by the discussion.
// This template will NOT produce warning
template Robert Ramey Remi Ricard wrote: Hi, I want to warn user about a possible miss use of a function. Now I'm only able to stop the compilation with the following code template <typename ValueType>
class simVec3 {
.........
/// Unary multiply by scalar.
/// @param rsh The scalar to multiply the vector with
template<class T> simVec3<ValueType>& operator *= (const T& rhs)
{
// The function should not be use like this
// simVec<int> vec(1, 1, 1);
// a *= 0.3; // since what a will contain is [0, 0, 0]
BOOST_MPL_ASSERT_NOT(( boost::mpl::and_< \
boost::is_floating_point<T>, \
boost::is_integral<ValueType> > )); ValueType s=static_cast<ValueType>(rhs);
vec[0]*=s; vec[1]*=s; vec[2]*=s; return *this;
} What I would want is something like
#if A_meta_function_returning_1_if_int_double
#pragma message("simVec::Possible type truncation")
#endif instead of the BOOST_MPL_ASSERT_NOT I also tried something like: template <bool x> struct AA;
template <> struct AA<true> { enum {value = 1 }; };
template <> struct AA<false> { enum {value = 0}; }; template return u + v;
} But the compilation is complaining about an unmatched parenthesis Remi _______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users