G
gsyoon
hi, all.
I'm trying to make a "framework" to store the return value of a
function to a global memory.
My first attempt was
1)
void store_to_global( char * type_name ) {
if ( strcmp( type_name, "CLASS_A") )
previously_allocated_mem = func() ;
...
}
However, there are some classes that override their
assignment operator and making it non-public.
(using copy constructors don't help much as they can
be overridden and made private).
So, I tried to memcpy as
2)
void store_to_global( char * type_name ) {
if ( strcmp( type_name, "CLASS_A") )
memcpy ( previously_allocated_mem, (void*) (&(func())), sizeof
(CLASS_A) ) ;
...
}
2) worked fine for gcc. However, for Solaris CC,
it caused a compile error like
"Error: The "&" operator can only be applied to a variable or other
l-value."
How can I make a general framework to store the return value of
function
regardless of their operators being overridden and made non-public
and the compilers used?
Any comments are welcomed.
Thanks in advance.
Gwang Sik Yoon.
I'm trying to make a "framework" to store the return value of a
function to a global memory.
My first attempt was
1)
void store_to_global( char * type_name ) {
if ( strcmp( type_name, "CLASS_A") )
previously_allocated_mem = func() ;
...
}
However, there are some classes that override their
assignment operator and making it non-public.
(using copy constructors don't help much as they can
be overridden and made private).
So, I tried to memcpy as
2)
void store_to_global( char * type_name ) {
if ( strcmp( type_name, "CLASS_A") )
memcpy ( previously_allocated_mem, (void*) (&(func())), sizeof
(CLASS_A) ) ;
...
}
2) worked fine for gcc. However, for Solaris CC,
it caused a compile error like
"Error: The "&" operator can only be applied to a variable or other
l-value."
How can I make a general framework to store the return value of
function
regardless of their operators being overridden and made non-public
and the compilers used?
Any comments are welcomed.
Thanks in advance.
Gwang Sik Yoon.