Arcane  v3.15.0.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
RawCopy.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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/* Structure de copie brute sans controle arithmétique. */
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// Specify specialization for all types to remove all implicit implementation
31// (when a new Arcane POD type will appear)
32
33template<>
34struct RawCopy<Byte> {
35 typedef Byte T;
36 inline static void copy(T & dst, const T & src) { dst = src; }
37};
38
39// Types without problem
40
41template<>
42struct RawCopy<Int16> {
43 typedef Int16 T;
44 inline static void copy(T & dst, const T & src) { dst = src; }
45};
46
47template<>
48struct RawCopy<Int8> {
49 typedef Int8 T;
50 inline static void copy(T & dst, const T & src) { dst = src; }
51};
52
53template<>
54struct RawCopy<Int32> {
55 typedef Int32 T;
56 inline static void copy(T & dst, const T & src) { dst = src; }
57};
58
59template<>
60struct RawCopy<Int64> {
61 typedef Int64 T;
62 inline static void copy(T & dst, const T & src) { dst = src; }
63};
64
65template<>
66struct RawCopy<String> {
67 typedef String T;
68 inline static void copy(T & dst, const T & src) { dst = src; }
69};
70
71// Types with problems
72
73#ifdef ARCANE_RAWCOPY
74
75#ifndef NO_USER_WARNING
76#warning "Using RawCopy for compact Variables"
77#endif /* NO_USER_WARNING */
78
79template<>
80struct RawCopy<Real> {
81 typedef Real T;
82 inline static void copy(T & dst, const T & src) {
83 reinterpret_cast<Int64&>(dst) = reinterpret_cast<const Int64&>(src);
84 }
85};
86
87template<>
88struct RawCopy<Real2> {
89 typedef Real2 T;
90 inline static void copy(T & dst, const T & src) {
91 reinterpret_cast<Int64&>(dst.x) = reinterpret_cast<const Int64&>(src.x);
92 reinterpret_cast<Int64&>(dst.y) = reinterpret_cast<const Int64&>(src.y);
93 }
94};
95
96template<>
97struct RawCopy<Real3> {
98 typedef Real3 T;
99 inline static void copy(T & dst, const T & src) {
100 reinterpret_cast<Int64&>(dst.x) = reinterpret_cast<const Int64&>(src.x);
101 reinterpret_cast<Int64&>(dst.y) = reinterpret_cast<const Int64&>(src.y);
102 reinterpret_cast<Int64&>(dst.z) = reinterpret_cast<const Int64&>(src.z);
103 }
104};
105
106template<>
107struct RawCopy<Real2x2> {
108 typedef Real2x2 T;
109 inline static void copy(T & dst, const T & src) {
110 reinterpret_cast<Int64&>(dst.x.x) = reinterpret_cast<const Int64&>(src.x.x);
111 reinterpret_cast<Int64&>(dst.x.y) = reinterpret_cast<const Int64&>(src.x.y);
112 reinterpret_cast<Int64&>(dst.y.x) = reinterpret_cast<const Int64&>(src.y.x);
113 reinterpret_cast<Int64&>(dst.y.y) = reinterpret_cast<const Int64&>(src.y.y);
114 }
115};
116
117template<>
118struct RawCopy<Real3x3> {
119 typedef Real3x3 T;
120 inline static void copy(T & dst, const T & src) {
121 reinterpret_cast<Int64&>(dst.x.x) = reinterpret_cast<const Int64&>(src.x.x);
122 reinterpret_cast<Int64&>(dst.x.y) = reinterpret_cast<const Int64&>(src.x.y);
123 reinterpret_cast<Int64&>(dst.x.z) = reinterpret_cast<const Int64&>(src.x.z);
124 reinterpret_cast<Int64&>(dst.y.x) = reinterpret_cast<const Int64&>(src.y.x);
125 reinterpret_cast<Int64&>(dst.y.y) = reinterpret_cast<const Int64&>(src.y.y);
126 reinterpret_cast<Int64&>(dst.y.z) = reinterpret_cast<const Int64&>(src.y.z);
127 reinterpret_cast<Int64&>(dst.z.x) = reinterpret_cast<const Int64&>(src.z.x);
128 reinterpret_cast<Int64&>(dst.z.y) = reinterpret_cast<const Int64&>(src.z.y);
129 reinterpret_cast<Int64&>(dst.z.z) = reinterpret_cast<const Int64&>(src.z.z);
130 }
131};
132
133#else /* ARCANE_RAWCOPY */
134
135template<>
136struct RawCopy<Real> {
137 typedef Real T;
138 inline static void copy(T & dst, const T & src) { dst = src; }
139};
140
141template<>
143 typedef BFloat16 T;
144 inline static void copy(T & dst, const T & src) { dst = src; }
145};
146
147template<>
149 typedef Float16 T;
150 inline static void copy(T & dst, const T & src) { dst = src; }
151};
152
153template<>
155 typedef Float32 T;
156 inline static void copy(T & dst, const T & src) { dst = src; }
157};
158
159
160template<>
161struct RawCopy<Real2> {
162 typedef Real2 T;
163 inline static void copy(T & dst, const T & src) { dst = src; }
164};
165
166template<>
167struct RawCopy<Real3> {
168 typedef Real3 T;
169 inline static void copy(T & dst, const T & src) { dst = src; }
170};
171
172template<>
174 typedef Real2x2 T;
175 inline static void copy(T & dst, const T & src) { dst = src; }
176};
177
178template<>
180 typedef Real3x3 T;
181 inline static void copy(T & dst, const T & src) { dst = src; }
182};
183
184#endif /* ARCANE_RAWCOPY */
185
186
187/*---------------------------------------------------------------------------*/
188/*---------------------------------------------------------------------------*/
189
190}
191
192/*---------------------------------------------------------------------------*/
193/*---------------------------------------------------------------------------*/
194
195#endif
196
Déclarations des types généraux de Arcane.
Classe gérant un vecteur de réel de dimension 2.
Definition Real2.h:121
Classe gérant une matrice de réel de dimension 2x2.
Definition Real2x2.h:53
Classe gérant un vecteur de réel de dimension 3.
Definition Real3.h:132
Classe gérant une matrice de réel de dimension 3x3.
Definition Real3x3.h:66
Type flottant demi-précision.
Chaîne de caractères unicode.
char * copy(char *to, const char *from)
Copie from dans to.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Arccore::Int8 Int8
Type représentant un entier sur 8 bits.
float Float32
Type flottant IEEE-753 simple précision (binary32)
unsigned char Byte
Type d'un octet.
Definition UtilsTypes.h:148