Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
COLLAPSE_TEMPLATE_LOCALS.cpp
Go to the documentation of this file.
1// checking static locals in template code
2
3
25#if 0 // guard invalid preprocessor symbol below
26
27 // establish a dependency on collapse_template_locals.lib.*
28# ifndef _RWSTD_NO_collapse_template_locals.lib
29
30 // link this compiled translation unit with the lib below
31 // LDOPTS = collapse_template_locals.lib$(LIBSUFFIX)
32
33# endif // _RWSTD_NO_collapse_template_locals.lib
34#endif // 0
35
36
37// also defined in collapse_template_locals.lib.cpp
38template <class T>
40{
41 // multiple instances of `t' must be collapsed
42 static T t;
43 return t++;
44}
45
46// bar() returns foo (0)
47extern int bar ();
48
49
50int main ()
51{
52 // compilers that corectly collapse static locals will
53 // behave as commented below (others will return 0 from bar())
54
55 int i = foo (0); // returns 0
56 int j = bar (); // should return 1
57
58 return !(i != j);
59}
#define i
Definition 17.names.cpp:126
#define T
Definition 17.names.cpp:163
#define t
Definition 17.names.cpp:136
#define j
Definition 17.names.cpp:127
#define foo(buf, s,...)