|
Boost Users : |
From: Benjamin Lau (blwy10v_at_[hidden])
Date: 2007-04-02 07:20:54
Hi all,
I'm writing a template class and I have several requirements on the
type parameters. A lot of it has to do with the inter-convertibility
of the types. I have 2 options to choose from as to how I can check
for these convertibility requirements: static assertions with the type
traits selector is_convertible, or using concept_check to check if the
assignment operation is defined for the types. Even though the former
leads to shorter code, the latter works just as well as I already have
concepts modeled for these types, so I could just dump the
inter-convertibility checks inside as well without much hassle.
In summary, I either choose this:
BOOST_STATIC_ASSERT((boost::is_convertible<T1, T2>::value));
or this:
template<class T1, class T2> class Concept
{
public:
void constraints()
{
// insert other constraints
a = b;
b = a;
}
T1 a;
T2 b;
};
Thanks a lot, and have a good day
Benjamin Lau
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