CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
dtype.h
Go to the documentation of this file.
1// -*- C++ -*-
14#ifndef __cxz_dynamic_meta_h__
15#define __cxz_dynamic_meta_h__
16
17#include <cstdlib>
18#include <utility>
19#include <memory>
20#include <any>
21#include <functional>
22
23#include "macros.h"
24#include "types.h"
25
26namespace CNORXZ
27{
31 class DType
32 {
33 private:
34 std::any mD;
35 std::function<String(const std::any&)> mToStr;
36 std::function<Int(const std::any&,const std::any&)> mComp;
37
38 template <typename T>
39 void _mkToStr();
40
41 template <typename T>
42 void _mkComp();
43
44 public:
53 template <typename T>
54 DType(const T& d);
55
62 template <typename T>
63 DType& operator=(const T& d);
64
66 String str() const { return mToStr(mD); }
67
69 const std::any& get() const { return mD; }
70
74 bool operator==(const DType& a) const { return mComp(mD,a.mD) == 0; }
75
79 bool operator!=(const DType& a) const { return mComp(mD,a.mD) != 0; }
80
84 bool operator<(const DType& a) const { return mComp(mD,a.mD) == -1; }
85
89 bool operator>(const DType& a) const { return mComp(mD,a.mD) == 1; }
90
94 bool operator<=(const DType& a) const { auto c = mComp(mD,a.mD); return c <= 0; }
95
99 bool operator>=(const DType& a) const { auto c = mComp(mD,a.mD); return c == 1 or c == 0; }
100 };
101
102} // namespace CNORXZ
103
104#endif
DType & operator=(const T &d)
Definition dtype.cc.h:34
bool operator>=(const DType &a) const
Definition dtype.h:99
const std::any & get() const
Definition dtype.h:69
bool operator!=(const DType &a) const
Definition dtype.h:79
DEFAULT_MEMBERS(DType)
bool operator<(const DType &a) const
Definition dtype.h:84
bool operator==(const DType &a) const
Definition dtype.h:74
bool operator>(const DType &a) const
Definition dtype.h:89
String str() const
Definition dtype.h:66
bool operator<=(const DType &a) const
Definition dtype.h:94
DType(const T &d)
Definition dtype.cc.h:27
useful macros
std::string String
Definition types.h:42
int32_t Int
Definition types.h:36
Sptr< Range > rangeCast(const RangePtr r)
Declaration of all library types.