Boost logo

Boost Users :

Subject: [Boost-users] [MPL] has_xxx always returns false!
From: Eric (elebel_at_[hidden])
Date: 2010-08-25 21:22:51


This code:

        BOOST_MPL_HAS_XXX_TRAIT_DEF(normal);

        template<class T, bool HasNormal>
        class getVertexHasNormal {
            public:
                static void getNormal(T &tv) {}
          };

        template<class T>
        class getVertexHasNormal<T, true> // true case
        {
            public:
                static void getNormal(T &tv) {
                 // do something
                }
        };

template<class VT>
class A : public base
{
      void doit(v) /* override */ {
         VT tv;
         getVertexHasNormal<VT, has_normal<VT>::value >::getNormal(tv);
      }
}

if I understand correctly, this code is suppose to do call a different
"getNormal" method if the method "normal" exists (or not) in the template
parameter class.

Basically mimicking the infamous "__if_exists" macro on the Microsoft c++
compiler.... right?

but, has_normal<VT> always return false (visual studio 2008) so we don't get the
right expected behavior!

Feel free to educate me....

thanks in advance.

eric


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