[Dune] what is a const template parameter?

Carsten Gräser graeser at mi.fu-berlin.de
Tue Jan 13 16:44:21 CET 2015


Am 13.01.2015 um 15:47 schrieb Aleksejs Fomins:
> Dear Dune,
> 
> Another quick question. When GeomGrid accesses the traits of a
> geometry from another class, for example, the entity class, it says
> sth like
> 
> typedef typename remove_const< Grid >::type::Traits Traits;
> 
> The entity is given in EntityPointerTraits as
> 
> Dune::Entity< codimension, dimension, const Grid, GeoGrid::Entity >
> Entity;
> 
> 
> Why would one prefer to use a const template parameter? In my
> ignorance I never even knew this was possible before I saw it here.
For any non-reference, non-function type there are also
cv-qualified versions, which are also types. I.e., if T
is a non-reference, non-function, non-const type, then

  const T, T&, const T&, ...

are also types which are different from T. You may want to read

  http://en.cppreference.com/w/cpp/language/type

for further reference.

Best,
Carsten

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20150113/63734b53/attachment.sig>


More information about the Dune mailing list