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
EXPLICIT_MEMBER_SPECIALIZATION.cpp
Go to the documentation of this file.
1
// checking for explicit member specialization
2
3
25
struct
A
26
{
27
int
i_
;
28
29
// no default ctor declared to exercise the compiler's ability
30
// distinguish between a declaration of an explicir member
31
// specialization and a definition of the same (see below)
32
A
(
int
i
):
i_
(
i
) { }
33
};
34
35
template
<
class
T>
36
struct
B
{
37
38
int
foo
() {
return
a
.i_; }
39
int
bar
();
40
41
static
A
a
;
42
};
43
44
// declare explicit specialization of template members
45
template
<>
inline
int
B<int>::foo
();
46
template
<>
int
B<int>::bar
();
47
48
// make sure this is taken as a declaration and not a definition
49
// as, for example, with SunPro 5.5 (see bug #411)
50
template
<>
A
B<int>::a
;
51
52
// define explicit specialization of template members
53
template
<>
inline
int
B<int>::foo
() {
return
1; }
54
template
<>
int
B<int>::bar
() {
return
1; }
55
template
<>
A
B<int>::a
(1);
56
57
// define members of the primary template
58
template
<
class
T>
int
B<T>::bar
() {
return
foo
(); }
59
template
<
class
T>
A
B<T>::a
(0);
60
61
int
main
()
62
{
63
B<char>
bc;
64
bc.
foo
();
65
bc.
bar
();
66
67
B<int>
bi;
68
69
int
status = 0;
70
71
if
(1 != bi.
foo
())
72
status |= 1;
73
74
if
(1 != bi.
bar
())
75
status |= 2;
76
77
if
(1 != bi.
a
.
i_
)
78
status |= 4;
79
80
return
status;
81
}
i
#define i
Definition
17.names.cpp:126
i_
#define i_
Definition
17.names.cpp:180
a
#define a
Definition
17.names.cpp:109
bar
int bar()
Definition
collapse_static_locals.lib.cpp:36
main
int main()
Definition
EXPLICIT_MEMBER_SPECIALIZATION.cpp:61
foo
#define foo(buf, s,...)
Definition
VA_LIST_FUNC_MACRO.cpp:28
A
Definition
NAMESPACE.cpp:25
B
Definition
NAMESPACE.cpp:31
A::i_
int i_
Definition
DUMMY_DEFAULT_ARG.cpp:39
A::A
A(int i)
Definition
EXPLICIT_MEMBER_SPECIALIZATION.cpp:32
B
Definition
DEFAULT_TEMPLATE_ARGS.cpp:29
B::a
static A a
Definition
EXPLICIT_MEMBER_SPECIALIZATION.cpp:41
B::foo
int foo()
Definition
EXPLICIT_MEMBER_SPECIALIZATION.cpp:38
B::bar
int bar()
Definition
EXPLICIT_MEMBER_SPECIALIZATION.cpp:58
Generated by
1.9.8