[Clam-devel] Const correctness in Processing Data
Pau Arumí Albó
parumi at iua.upf.edu
Tue Apr 29 10:24:09 PDT 2008
El dl 28 de 04 del 2008 a les 23:07 +0200, en/na Xavier Amatriain va
escriure:
> Uhm... maybe we already talked about this at some point but it just
> struck me:
>
> If you look at, for example, AudioFileOut.cxx:147 you see the following
> line:
>
> DataArray &array = in.GetBuffer();
>
> The problem is that the in variable has been passed as "const" but is
> being assigned a non const reference. The corrected line should be
>
> const DataArray &array = in.GetBuffer();
>
> If you replace the Audio class by a non Dynamic Type class, the compiler
> complains and forces you to do the 2nd. Why isn't this the
> case with DTs? Isn't this a bit "spooky"? :-)
>
> X
You are right.
But there is no way i can conceive to implement this because a GetXxx()
from a DynamicType does not returns a reference to a member but a
reference to a dynamic memory chunk.
Well there is a way to fix it: changing the DT macros implementation to
use normal attributes. This is a kind of long lived TODO i think...
Pau
PS: But change the line to const, of course!
More information about the clam-devel
mailing list