Strange signatures for IndexSet and IdSet methods taking an entity

IndexSet and IdSet have implement (nearly) all methods taking an entity twice, e.g.,

Index index ( const Entity &entity ) const
{
  return index< Entity::codimension >( entity );
}

template< int cc >
Index index ( const typename GridImp::template Codim< cc >::Entity &entity ) const
{
  return asImp().index< cc >( entity );
}

The implementation then only implements the method index< cc >. This has the downside, that the implementation has to use IndexSet::index to provide the first version, if not casted down to the interface.

As far as I know, the purpose of this technique is to ensure the type Entity coinsides with typename GridImp::template Codim< cc >::Entity. Today, this could also be done by an SFINAE:

template< class Entity , std::enable_if_t< std::is_same< Entity, typename GridImp::template Codim< Entity::codimension >::Entity >::value, int > = 0 >
Index index ( const Entity &entity ) const
{
  asImp().index( entity );
}

This way, the interface would still protect the method index from being called with a wrong entity type.

I propose to use the SFINAE version, here. However, this will break implementations, unless we use another SFINAE trick to detect the implementation (and use proper deprecation).

Assignee Loading
Time tracking Loading