TAMSVIZ
Visualization and annotation tool for ROS
Main Page
Classes
Files
File List
src
core
variant.h
1
// TAMSVIZ
2
// (c) 2020 Philipp Ruppel
3
4
#pragma once
5
6
#include <memory>
7
#include <typeindex>
8
9
class
Variant
{
10
std::shared_ptr<void> _ptr =
nullptr
;
11
std::type_index _type =
typeid
(void);
12
13
public
:
14
std::type_index type()
const
{
return
_type; }
15
template
<
class
T>
const
T &value()
const
{
16
return
*
static_cast<
const
T *
>
(_ptr.get());
17
}
18
template
<
class
T>
void
assign(
const
T &v) {
19
_type =
typeid
(T);
20
_ptr = std::make_shared<T>(v);
21
}
22
Variant
() {}
23
template
<
class
T>
explicit
Variant
(
const
T &v) { assign(v); }
24
void
clear() {
25
_ptr =
nullptr
;
26
_type =
typeid
(void);
27
}
28
};
Variant
Definition:
variant.h:9
Generated by
1.8.11