TechArena Community

TechArena Community (http://forums.techarena.in/)
-   Software Development (http://forums.techarena.in/software-development/)
-   -   C++ keyword search for the functions (http://forums.techarena.in/software-development/1078493.htm)

LadyMedusa 27-11-2008 02:50 PM

C++ keyword search for the functions
 
a few months ago I read something ABOUT a certain key word that I can not find.

The principle was that if a function depends solely on its parameters (not rand, or dependence on time or on a variable-volatile), the compiler could save the result in memory to optimize the next call.

Code:

int foo (int a)
(
return a + 2;
)
void main ()
(
foo (5);
foo (5);
)

foo here would be called once the 2nd time and the result is already in memory.
In my memory function was called 'pure' but looking on this key word I do not think 'pure virtual' ...

Matellis 27-11-2008 02:57 PM

Re: C++ keyword search for the functions
 
You can wrap each attribute in a macro and vary according to the macro compilos.

paintbox 27-11-2008 03:03 PM

Re: C++ keyword search for the functions
 
Under gcc you __attribute__ ((pure)) and __attribute__ ((const)), but otherwise nothing portable.
You can wrap each attribute in a macro and vary according to the macro compilos.


All times are GMT +5.5. The time now is 05:54 AM.