This is more like the C++ name "resolution". In your case, you have a pointer to a const DM
, but you want a const pointer, so you must use typedef dm_const_t const & dm_cref_t
(a const reference to a const pointer)
Giving more details:
When you declare const int * a
, you are saying that a
is a constant pointer to an integer. It is the same as int const * a
.
If you want a reference to a type, you declare int & b
, meaning that b
is a reference to an integer. Thinking the same way, const int & c
is the same as int const & c
(const always qualify the variable, not the type).
So, if you want a const reference to a const pointer, using the second notation is clearer (and the only one possible if not using typedef
s): int const * const & d
, meaning d
is a constant reference to a constant pointer to an integer. Using typedefs:
typedef const int * int_cptr;
typedef const int_cptr & int_cptrcref;
Proof: http://ideone.com/V48Kxe