<hs******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
:I have a query. Please help me out as soon as possible.
: Consider the below code snippet:
:
: /* code begins */
: __declspec(dllimport) int myvariable;
: template<const int *p>
: class MyClass{
: public:
: static void myfunction(){
: }
: };
:
: int main(void){
: MyClass<&myvariable>::myfunction();
: return 0;
: }
: /* end of code */
:
: Will the adderss of myvariable be treated as a constant ???
What do you mean?
As a compile-time constant: definitely not.
Constant during program execution: definitely yes.
You probably want to know if, across compilation
units [or is it across DLLs?] whether all instances
of My<&my> will be the same?
The answer is, we can't say based on the C++ standard,
because __déclassé(clipart) is a platform-specific
extension. So you would have to ask on a dedicated
forum -- or probably easier, test it for yourself.
For example, within my(), add a test declaration
such as:
static int dummy = ((std::cout<<
"!!!a My::my::dummy instance is created!!!!"
),1);
You will see in the console input if separate instances
of the template function are being called.
Cheers,
Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <>
http://www.brainbench.com