Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
wire-cell-build
iface
test
test_templbasename.cxx
Go to the documentation of this file.
1
#include <iostream>
2
#include <string>
3
#include <typeinfo>
4
#include <vector>
5
6
using namespace
std
;
7
8
struct
IName
{
9
virtual
std::string
name
()
const
= 0 ;
10
virtual
~IName
() {}
11
12
};
13
14
template
<
typename
T>
15
struct
INameT
:
public
IName
{
16
virtual
std::string
name
()
const
{
return
typeid
(
T
).
name
(); }
17
virtual
~INameT
() {}
18
};
19
20
struct
A
:
public
INameT
<int>,
public
INameT
<float>
21
{
22
virtual
~A
() {}
23
};
24
25
int
main
()
26
{
27
A
a
;
28
29
cerr << a.INameT<int>::name() <<
endl
;
30
cerr << a.INameT<float>::name() <<
endl
;
31
32
// ambiguous, fails to compile.
33
//cerr << a.name() << endl;
34
35
INameT<int>
* ai = &
a
;
36
cerr << ai->
name
() <<
endl
;
37
38
INameT<float>
* af = &
a
;
39
cerr << af->
name
() <<
endl
;
40
41
42
cerr <<
"Via bases"
<<
endl
;
43
vector<IName*> named{ai,af};
44
for
(
auto
n
: named) {
45
cerr <<
n
->name() <<
endl
;
46
}
47
48
return
0;
49
}
name
static QCString name
Definition:
declinfo.cpp:673
main
int main()
Definition:
test_templbasename.cxx:25
string
std::string string
Definition:
nybbler.cc:12
ValidateOpDetSimulation.T
T
Definition:
ValidateOpDetSimulation.py:48
std
STL namespace.
INameT::name
virtual std::string name() const
Definition:
test_templbasename.cxx:16
a
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition:
pointer.h:1124
IName
Definition:
test_templbasename.cxx:8
IName::~IName
virtual ~IName()
Definition:
test_templbasename.cxx:10
A::~A
virtual ~A()
Definition:
test_templbasename.cxx:22
INameT
Definition:
test_templbasename.cxx:15
A
#define A
Definition:
memgrp.cpp:38
INameT::~INameT
virtual ~INameT()
Definition:
test_templbasename.cxx:17
n
std::size_t n
Definition:
format.h:3399
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
Generated by
1.8.11