CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
dtype.cc.h
Go to the documentation of this file.
1// -*- C++ -*-
14#ifndef __cxz_dtype_cc_h__
15#define __cxz_dtype_cc_h__
16
17#include <sstream>
18#include "dtype.h"
19#include "to_string.h"
20
21namespace CNORXZ
22{
23 // for tuple use vector<DType> !!!
24 // (yes DType is slow, thats why one should only use it for debugging)
25
26 template <typename T>
27 DType::DType(const T& d) : mD(d)
28 {
30 _mkComp<T>();
31 }
32
33 template <typename T>
35 {
36 mD = d;
38 _mkComp<T>();
39 return *this;
40 }
41
42 template <typename T>
43 void DType::_mkToStr()
44 {
45 mToStr = [](const std::any& d){
46 return toString(std::any_cast<T>(d));
47 };
48 }
49
50 template <typename T>
51 void DType::_mkComp()
52 {
53 mComp = [](const std::any& d, const std::any& a){
54 if(d.type() != a.type()){
55 return 2;
56 }
57 else {
58 auto& at = std::any_cast<const T&>(a);
59 auto& dt = std::any_cast<const T&>(d);
60 if(std::equal_to<T>{}(dt,at)){
61 return 0;
62 }
63 else if(std::less<T>{}(dt,at)){
64 return -1;
65 }
66 else {
67 return 1;
68 }
69 }
70 };
71 }
72}
73
74#endif
DType & operator=(const T &d)
Definition dtype.cc.h:34
DType(const T &d)
Definition dtype.cc.h:27
DType declaration.
Sptr< Range > rangeCast(const RangePtr r)
String toString(const T &a)
String converter declarations.