Boost logo

Boost :

Subject: [boost] [type_eraseure]Why not make default concept_interface a metafunction returning Base?
From: Larry Evans (cppljevans_at_[hidden])
Date: 2012-08-31 08:58:47


Since the unspecialized concept_iterface definition:

  template<class Concept, class Base, class ID, class Enable = void>
  struct concept_interface : Base {};

does nothing, and it's used to compose the any base class heirarchy
in:

  template<class Derived, class Concept, class T>
  struct compute_bases
  {
      typedef typename ::boost::mpl::fold<
          typename ::boost::type_erasure::detail::collect_concepts<
              Concept
>::type,
          ::boost::type_erasure::any_base<Derived>,
          ::boost::type_erasure::concept_interface<
              ::boost::mpl::_2,
              ::boost::mpl::_1,
              T
>
>::type type;
  };

why not eliminate the empty concept_interfaces by redefining the
unspecialized concept_interface to:

  template<class Concept, class Base, class ID, class Enable = void>
  struct concept_interface : Base
  {
      //The following enables mpl::fold, when using
      //this as the binary operator, to skip this
      //empty interface.
      typedef Base type;
  };

I believe that would work since mpl::fold uses the nested type if it's
available, IIUC.

Although it would not change the behaviour of any code, it would make
the intent of the code clearer. Also, while trying to understand what
the code is doing by using a type name demangler, I found all those
empty concept_interfaces are just noise.

-regards,
Larry


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk