Chris Goller wrote:
David-
First, thanks for the response. BTW, I really like the book.
Okay, I understand what you are saying about add_const and how it works.
My next question is why was it implemented in that way? In other words, was there a specific reason not to make a special case for references such that add_const
would be int const &?
FWIW, you will soon be able to get that effect without a metafunction. from http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#106 [example] int i; typedef int& RI; RI& r = i; // r has the type int& const RI& r = i; // r has the type const int& [/example] I'm not sure I like it, because a 'RI const' is 'int&', but a reference to a 'RI const' is 'int const&'. But maybe its useful that way. Cheers, Ian McCulloch