Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
RawCopy.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* RawCopy.h (C) 2000-2024 */
9/* */
10/* Raw copy structure without arithmetic control. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_RAWCOPY_H
13#define ARCANE_CORE_RAWCOPY_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28template <typename T> struct RawCopy
29{};
30
31// Specify specialization for all types to remove all implicit implementation
32// (when a new Arcane POD type will appear)
33
34template <>
36{
37 typedef Byte T;
38 inline static void copy(T& dst, const T& src) { dst = src; }
39};
40
41// Types without problem
42
43template <>
45{
46 typedef Int16 T;
47 inline static void copy(T& dst, const T& src) { dst = src; }
48};
49
50template <>
52{
53 typedef Int8 T;
54 inline static void copy(T& dst, const T& src) { dst = src; }
55};
56
57template <>
59{
60 typedef Int32 T;
61 inline static void copy(T& dst, const T& src) { dst = src; }
62};
63
64template <>
66{
67 typedef Int64 T;
68 inline static void copy(T& dst, const T& src) { dst = src; }
69};
70
71template <>
73{
74 typedef String T;
75 inline static void copy(T& dst, const T& src) { dst = src; }
76};
77
78// Types with problems
79
80#ifdef ARCANE_RAWCOPY
81
82#ifndef NO_USER_WARNING
83#warning "Using RawCopy for compact Variables"
84#endif /* NO_USER_WARNING */
85
86template <>
87struct RawCopy<Real>
88{
89 typedef Real T;
90 inline static void copy(T& dst, const T& src)
91 {
92 reinterpret_cast<Int64&>(dst) = reinterpret_cast<const Int64&>(src);
93 }
94};
95
96template <>
97struct RawCopy<Real2>
98{
99 typedef Real2 T;
100 inline static void copy(T& dst, const T& src)
101 {
102 reinterpret_cast<Int64&>(dst.x) = reinterpret_cast<const Int64&>(src.x);
103 reinterpret_cast<Int64&>(dst.y) = reinterpret_cast<const Int64&>(src.y);
104 }
105};
106
107template <>
108struct RawCopy<Real3>
109{
110 typedef Real3 T;
111 inline static void copy(T& dst, const T& src)
112 {
113 reinterpret_cast<Int64&>(dst.x) = reinterpret_cast<const Int64&>(src.x);
114 reinterpret_cast<Int64&>(dst.y) = reinterpret_cast<const Int64&>(src.y);
115 reinterpret_cast<Int64&>(dst.z) = reinterpret_cast<const Int64&>(src.z);
116 }
117};
118
119template <>
120struct RawCopy<Real2x2>
121{
122 typedef Real2x2 T;
123 inline static void copy(T& dst, const T& src)
124 {
125 reinterpret_cast<Int64&>(dst.x.x) = reinterpret_cast<const Int64&>(src.x.x);
126 reinterpret_cast<Int64&>(dst.x.y) = reinterpret_cast<const Int64&>(src.x.y);
127 reinterpret_cast<Int64&>(dst.y.x) = reinterpret_cast<const Int64&>(src.y.x);
128 reinterpret_cast<Int64&>(dst.y.y) = reinterpret_cast<const Int64&>(src.y.y);
129 }
130};
131
132template <>
133struct RawCopy<Real3x3>
134{
135 typedef Real3x3 T;
136 inline static void copy(T& dst, const T& src)
137 {
138 reinterpret_cast<Int64&>(dst.x.x) = reinterpret_cast<const Int64&>(src.x.x);
139 reinterpret_cast<Int64&>(dst.x.y) = reinterpret_cast<const Int64&>(src.x.y);
140 reinterpret_cast<Int64&>(dst.x.z) = reinterpret_cast<const Int64&>(src.x.z);
141 reinterpret_cast<Int64&>(dst.y.x) = reinterpret_cast<const Int64&>(src.y.x);
142 reinterpret_cast<Int64&>(dst.y.y) = reinterpret_cast<const Int64&>(src.y.y);
143 reinterpret_cast<Int64&>(dst.y.z) = reinterpret_cast<const Int64&>(src.y.z);
144 reinterpret_cast<Int64&>(dst.z.x) = reinterpret_cast<const Int64&>(src.z.x);
145 reinterpret_cast<Int64&>(dst.z.y) = reinterpret_cast<const Int64&>(src.z.y);
146 reinterpret_cast<Int64&>(dst.z.z) = reinterpret_cast<const Int64&>(src.z.z);
147 }
148};
149
150#else /* ARCANE_RAWCOPY */
151
152template <>
154{
155 typedef Real T;
156 inline static void copy(T& dst, const T& src) { dst = src; }
157};
158
159template <>
161{
162 typedef BFloat16 T;
163 inline static void copy(T& dst, const T& src) { dst = src; }
164};
165
166template <>
168{
169 typedef Float16 T;
170 inline static void copy(T& dst, const T& src) { dst = src; }
171};
172
173template <>
175{
176 typedef Float32 T;
177 inline static void copy(T& dst, const T& src) { dst = src; }
178};
179
180template <>
182{
183 typedef Real2 T;
184 inline static void copy(T& dst, const T& src) { dst = src; }
185};
186
187template <>
189{
190 typedef Real3 T;
191 inline static void copy(T& dst, const T& src) { dst = src; }
192};
193
194template <>
196{
197 typedef Real2x2 T;
198 inline static void copy(T& dst, const T& src) { dst = src; }
199};
200
201template <>
203{
204 typedef Real3x3 T;
205 inline static void copy(T& dst, const T& src) { dst = src; }
206};
207
208#endif /* ARCANE_RAWCOPY */
209
210/*---------------------------------------------------------------------------*/
211/*---------------------------------------------------------------------------*/
212
213} // namespace Arcane
214
215/*---------------------------------------------------------------------------*/
216/*---------------------------------------------------------------------------*/
217
218#endif
Declarations of Arcane's general types.
Half-precision floating-point type.
Class managing a 2-dimensional real vector.
Definition Real2.h:122
Class managing a 2x2 matrix of reals.
Definition Real2x2.h:55
Class managing a 3-dimensional real vector.
Definition Real3.h:132
Class managing a 3x3 real matrix.
Definition Real3x3.h:67
char * copy(char *to, const char *from)
Copies from into to.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int8_t Int8
Signed integer type of 8 bits.
std::int64_t Int64
Signed integer type of 64 bits.
std::int16_t Int16
Signed integer type of 16 bits.
double Real
Type representing a real number.
unsigned char Byte
Type of a byte.
Definition BaseTypes.h:43
float Float32
IEEE-753 single-precision floating-point type.
std::int32_t Int32
Signed integer type of 32 bits.