2 #ifndef FORPY_UTIL_STORAGE_H_ 3 #define FORPY_UTIL_STORAGE_H_ 7 #pragma GCC diagnostic push 8 #pragma GCC diagnostic ignored "-Wreturn-local-addr" 11 #include <mapbox/variant_cast.hpp> 14 #pragma GCC diagnostic pop 17 #include "./serialization/variant.h" 54 template <
typename... Ts>
56 using Base = mu::variant<Ts...>;
68 template <
typename Archive>
81 stream <<
"forpy::Empty";
92 template <
typename T,
typename U>
98 return lhs.isApprox(rhs);
116 template <
template <
typename>
class STOT>
118 std::shared_ptr<const STOT<float>>, std::shared_ptr<const STOT<double>>,
119 std::shared_ptr<const STOT<uint>>, std::shared_ptr<const STOT<uint8_t>>>;
124 template <
template <
typename>
class STOT>
125 using Data =
typename mu::variant<Empty, STOT<float>, STOT<double>, STOT<uint>,
128 using DataV =
typename mu::variant<std::vector<float>, std::vector<double>,
129 std::vector<uint>, std::vector<uint8_t>>;
135 template <
typename T>
137 typedef typename std::remove_pointer<T>::type
_tmp;
138 typedef typename std::remove_reference<_tmp>::type
__tmp;
139 typedef typename std::remove_cv<__tmp>::type
type;
142 template <
typename V,
class... VarArgs>
144 const std::unordered_map<std::string, mu::variant<VarArgs...>> &m,
145 std::string
const &key,
const V &defval) {
146 typename std::unordered_map<std::string,
147 mu::variant<VarArgs...>>::const_iterator it =
149 if (it == m.end())
return defval;
150 return mu::static_variant_cast<V>(it->second);
154 #endif // FORPY_UTIL_STORAGE_H_ V GetWithDefVar(const std::unordered_map< std::string, mu::variant< VarArgs... >> &m, std::string const &key, const V &defval)
size_t & innerStride() const
bool operator()(const Empty &, const Empty &)
std::remove_cv< __tmp >::type type
std::remove_reference< _tmp >::type __tmp
bool operator==(const Empty &) const
bool operator()(const T &, const U &)
void serialize(Archive &, const uint &)
typename mu::variant< Empty, STOT< float >, STOT< double >, STOT< uint >, STOT< uint8_t > > Data
Storing a variant of the provided data container type.
typename mu::variant< std::shared_ptr< const STOT< float > >, std::shared_ptr< const STOT< double > >, std::shared_ptr< const STOT< uint > >, std::shared_ptr< const STOT< uint8_t > >> DataStore
Variant for storing shared_ptrs to the stored data matrix type.
friend std::ostream & operator<<(std::ostream &stream, const Empty &)
typename mu::variant< std::vector< float >, std::vector< double >, std::vector< uint >, std::vector< uint8_t > > DataV
void operator()(T &pointer) const
std::remove_pointer< T >::type _tmp
A struct to represent an empty variant.
Call the reset operation on a pointer variant.
mu::variant< Ts... > Base
bool operator()(const T &lhs, const T &rhs)
size_t & outerStride() const
Get the core datatype with removed pointer, reference and const modifiers.
unsigned int uint
Convenience typedef for unsigned int.