Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Main Page
Related Pages
Topics
Namespaces
Data Structures
Files
File List
Globals
EXTERNAL_HEADERS
RSL
etc
config
src
COLLAPSE_TEMPLATE_STATICS.cpp
Go to the documentation of this file.
1
// checking static template members
2
3
25
#if 0
// guard invalid preprocessor symbol below
26
27
// establish a dependency on collapse_template_statics.lib.*
28
# ifndef _RWSTD_NO_collapse_template_statics.lib
29
30
// link this compiled translation unit with the lib below
31
// LDOPTS = collapse_template_statics.lib$(LIBSUFFIX)
32
33
# endif
// _RWSTD_NO_collapse_template_statics.lib
34
#endif
// 0
35
36
37
// also defined in collapse_template_statics.lib.cpp
38
template
<
class
T>
39
struct
S
40
{
41
// multiple instances of `t' must be collapsed
42
static
T
t
;
43
};
44
45
template
<
class
T>
46
T
S<T>::t
;
47
48
49
// bar() returns S<int>::t++
50
extern
int
bar
();
51
52
53
int
main
()
54
{
55
// compilers that corectly collapse static template members
56
// behave as commented below (others will return 0 from bar())
57
58
int
i
=
S<int>::t
++;
// yields 0
59
int
j
=
bar
();
// should return 1
60
61
return
!(
i
!=
j
);
62
}
i
#define i
Definition
17.names.cpp:126
T
#define T
Definition
17.names.cpp:163
j
#define j
Definition
17.names.cpp:127
bar
int bar()
Definition
collapse_static_locals.lib.cpp:36
main
int main()
Definition
COLLAPSE_TEMPLATE_STATICS.cpp:53
S
Definition
COLLAPSE_TEMPLATE_STATICS.cpp:40
S::t
static T t
Definition
COLLAPSE_TEMPLATE_STATICS.cpp:42
Generated by
1.9.8