Arcane  v4.1.1.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
common/arccore/common/ArrayTraits.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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/* ArrayTraits.h (C) 2000-2025 */
9/* */
10/* Caractéristiques d'un tableau 1D. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_COMMON_ARRAYTRAITS_H
13#define ARCCORE_COMMON_ARRAYTRAITS_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/common/CommonGlobal.h"
18
19// Pour std::byte
20#include <cstddef>
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arccore
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30/*!
31 * \brief Caractéristiques pour un tableau.
32 *
33 * Cette classe template peut être spécialisée pour indiquer qu'un type doit
34 * être considéré comme un type POD pour les classes tableaux (Array, Array2, ...).
35 *
36 * Pour ces classes, si un type est un type POD, alors les constructeurs, destructeurs
37 * et opérateurs de recopies ne sont pas appelés pour gérer les instances de ce
38 * type dans les tableaux.
39 *
40 * Pour indiquer qu'un type doit être considéré comme un type POD, il faut
41 * utiliser la macro ARCCORE_DEFINE_ARRAY_PODTYPE.
42 */
43template <typename T>
45{
46 public:
47
48 typedef const T& ConstReferenceType;
49 typedef FalseType IsPODType;
50};
51
52/*---------------------------------------------------------------------------*/
53/*---------------------------------------------------------------------------*/
54
55/*!
56 * \brief Macro pour indiquer que le type \a datatype est un type POD pour les tableaux.
57 *
58 * Cette macro spécialise \a Arccore::ArrayTraits pour le type \a datatype. Elle
59 * donc être utilisé dans le namespace \a Arccore et avant l'utilisation du
60 * type \a datatype.
61 */
62#define ARCCORE_DEFINE_ARRAY_PODTYPE(datatype) \
63 template <> \
64 class ArrayTraits<datatype> \
65 { \
66 public: \
67\
68 typedef datatype ConstReferenceType; \
69 typedef TrueType IsPODType; \
70 }
71
72/*---------------------------------------------------------------------------*/
73/*---------------------------------------------------------------------------*/
74//! Implémentation par défaut indiquant qu'un type n'est pas POD
75template <typename T>
76class ArrayTraits<T*>
77{
78 public:
79
80 typedef T* Ptr;
81 typedef const Ptr& ConstReferenceType;
82 typedef FalseType IsPODType;
83};
84
85//! Implémentation par défaut indiquant qu'un type n'est pas POD
86template <typename T>
87class ArrayTraits<const T*>
88{
89 public:
90
91 typedef T* Ptr;
92 typedef const T* ConstReferenceType;
93 typedef FalseType IsPODType;
94};
95
96/*---------------------------------------------------------------------------*/
97/*---------------------------------------------------------------------------*/
98
99ARCCORE_DEFINE_ARRAY_PODTYPE(char);
100ARCCORE_DEFINE_ARRAY_PODTYPE(signed char);
101ARCCORE_DEFINE_ARRAY_PODTYPE(unsigned char);
102ARCCORE_DEFINE_ARRAY_PODTYPE(short);
103ARCCORE_DEFINE_ARRAY_PODTYPE(int);
104ARCCORE_DEFINE_ARRAY_PODTYPE(long);
105ARCCORE_DEFINE_ARRAY_PODTYPE(unsigned short);
106ARCCORE_DEFINE_ARRAY_PODTYPE(unsigned int);
107ARCCORE_DEFINE_ARRAY_PODTYPE(unsigned long);
108ARCCORE_DEFINE_ARRAY_PODTYPE(float);
109ARCCORE_DEFINE_ARRAY_PODTYPE(double);
110ARCCORE_DEFINE_ARRAY_PODTYPE(long double);
111ARCCORE_DEFINE_ARRAY_PODTYPE(std::byte);
112ARCCORE_DEFINE_ARRAY_PODTYPE(Float16);
113ARCCORE_DEFINE_ARRAY_PODTYPE(BFloat16);
114
115/*---------------------------------------------------------------------------*/
116/*---------------------------------------------------------------------------*/
117
118} // namespace Arccore
119
120/*---------------------------------------------------------------------------*/
121/*---------------------------------------------------------------------------*/
122
123#endif
Caractéristiques pour un tableau.
Espace de nom de Arccore.
Arcane::BFloat16 BFloat16
Type 'Brain Float16'.
Arcane::Float16 Float16
Type 'Float16' (binary16)