h5cpp 0.7
A modern C++ wrapper for the HDF5 C library
Loading...
Searching...
No Matches
complex.hpp
Go to the documentation of this file.
1//
2// (c) Copyright 2021 DESY, ESS
3// 2021 Eugen Wintersberger <eugen.wintersberger@gmail.com>
4//
5// This file is part of h5cpp.
6//
7// This library is free software; you can redistribute it and/or modify it
8// under the terms of the GNU Lesser General Public License as published
9// by the Free Software Foundation; either version 2.1 of the License, or
10// (at your option) any later version.
11//
12// This library is distributed in the hope that it will be useful, but
13// WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY
14// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15// License for more details.
16//
17// You should have received a copy of the GNU Lesser General Public License
18// along with this library; if not, write to the
19// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor
20// Boston, MA 02110-1301 USA
21// ===========================================================================
22//
23// Authors: Eugen Wintersberger <eugen.wintersberger@desy.de>
24// Created on: Dec 23, 2021
25//
26#pragma once
27
29#include <complex>
30
31namespace hdf5 {
32namespace datatype {
33
34template<typename T>
35class TypeTrait<std::complex<T>>
36{
37 private:
38 using element_type = TypeTrait<T>;
39
40 public:
41 using Type = std::complex<T>;
42 using TypeClass = Compound;
43
44 static TypeClass create(const Type & = Type())
45 {
46 datatype::Compound type = datatype::Compound::create(
47 sizeof(std::complex<T>));
48
49 type.insert("real", 0, element_type::create(T()));
50 type.insert("imag", alignof(T), element_type::create(T()));
51
52 return type;
53 }
54 const static TypeClass & get(const Type & = Type()) {
55 const static TypeClass & cref_ = create();
56 return cref_;
57 }
58};
59}
60}
static Compound create(size_t size)
constructor
Datatype TypeClass
subtype of Datatype which will be used
Definition type_trait.hpp:58
static TypeClass create(const T &=T())
create the new type instance
static const TypeClass & get(const T &=T())
reference to const static type instance
Type
Definition type.hpp:43
@ Compound
indicates a compound type
top-level namespace of the entire library
Definition attribute.hpp:45