[Exceptional C++ Style] Exceptional C++ Style - Item 24: ConstantOptimization

Balog Pal pasa at lib.hu
Mon Jan 24 14:15:24 EST 2005


>> An old guideline said const  (non-ref) params belong to the
>> *impelmentation
>> details*. So in headers and function interfaces const shall
>> be omitted (it's
>> discarded by the compiler anyway).
>
> True but it can be useful documentation for the caller.

Come again?  You see in a header:

void foo1(int param);
void foo2(const int param);

As a caller what information can you deduce from that const?

If you pass address in pointer or by-reference, it's certainly vital 
information, but when you bass by value what is the caller's concern what 
happens to the copy the callee gets?






More information about the Effective-cpp mailing list