rcpp_framework/libs/brynet/base/Any.hpp

31 lines
486 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
namespace brynet { namespace base {
#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-04-30 16:10:14 +02:00
template<typename T>
auto cast(const BrynetAny& ud)
{
return std::any_cast<T>(&ud);
}
2020-11-24 15:41:18 +01:00
#else
2021-04-30 16:10:14 +02:00
using BrynetAny = int64_t;
template<typename T>
const T* cast(const BrynetAny& ud)
{
return static_cast<const T*>(&ud);
}
2020-11-24 15:41:18 +01:00
#endif
2021-04-30 16:10:14 +02:00
}}// namespace brynet::base