B
bill
I recently realized that I have a structure that I'd like to put more
protection on in the following sense: I'd like to modify
struct foo{
int *x;
} ;
to be:
struct foo {
const int *x;
}
I see only 2 choices (3 if I count not making the change):
1) modify the structure and all functions that initialize instances of
it
2) define struct const_foo {const int *x;}, change the formal
parameter list of all functions that used to take a const foo *
argument to take a const const_foo * instead, and cast all
calls.
I'm not particularly fond of either solution. #1 is aesthetically
appealing (ie, it's the proper thing to do), #2 would be much
faster to implement in this case, but seems to be a kludge.
It seems as if I'm implementing the const keyword to
make "const foo *" mean "const foo */w const *x" and
is pretty ugly.
Can anyone suggest another solution?
protection on in the following sense: I'd like to modify
struct foo{
int *x;
} ;
to be:
struct foo {
const int *x;
}
I see only 2 choices (3 if I count not making the change):
1) modify the structure and all functions that initialize instances of
it
2) define struct const_foo {const int *x;}, change the formal
parameter list of all functions that used to take a const foo *
argument to take a const const_foo * instead, and cast all
calls.
I'm not particularly fond of either solution. #1 is aesthetically
appealing (ie, it's the proper thing to do), #2 would be much
faster to implement in this case, but seems to be a kludge.
It seems as if I'm implementing the const keyword to
make "const foo *" mean "const foo */w const *x" and
is pretty ugly.
Can anyone suggest another solution?