rcpp_framework/libs/brynet/base/Any.hpp

25 lines
417 B
C++
Raw Normal View History

2020-11-24 15:41:18 +01:00
#pragma once
#include <brynet/base/CPP_VERSION.hpp>
#ifdef BRYNET_HAVE_LANG_CXX17
#include <any>
#else
#include <cstdint>
#endif
#ifdef BRYNET_HAVE_LANG_CXX17
2021-04-30 16:10:14 +02:00
using BrynetAny = std::any;
2020-11-24 15:41:18 +01:00
2021-05-14 17:16:45 +02:00
template <typename T>
auto cast(const BrynetAny &ud) {
return std::any_cast<T>(&ud);
2021-04-30 16:10:14 +02:00
}
2020-11-24 15:41:18 +01:00
#else
2021-04-30 16:10:14 +02:00
using BrynetAny = int64_t;
2021-05-14 17:16:45 +02:00
template <typename T>
const T *cast(const BrynetAny &ud) {
return static_cast<const T *>(&ud);
2021-04-30 16:10:14 +02:00
}
2020-11-24 15:41:18 +01:00
#endif