nicolas.sitbon said:
"nicolas.sitbon" <
[email protected]> writes:
It is best to snip sigs unless you are commenting on them.
thanks for your answer, in fact, I don't need to change the
qualifiers, rather I'm looking for a way to create a generic data
structure that can can be used with const generic pointer or non const
generic pointer, preventing the user from casting if I would hard code
the qualifier.
If you hard-code the const, why does the user have to cast?
Think of a generic linked list where you can put const
data or variable data without casting because I would code void * data
and the user want to put a const char *.
As a rule, generic container structures don't know enough about the
data to do anything much with it (they may pass it to a function but
that is about it). That makes me wonder why you need the non-const
data variant.
I hope it is clear, english is not my mother tongue.
Yes, perfectly clear. Your English is excellent. While on the
subject of language, pointers are problematic. You talk about a
"const generic pointer or non const generic pointer" but in fact the
pointer is not const qualified in either case, it is the data pointed
*to* that is marked const. This is not a complaint -- everyone drops
into shorthands like this all the time -- but sometimes it matters and
it pays to be vigilant for those cases where they might be a
misunderstanding.