Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ArrayView.cc
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/* ArrayView.cc (C) 2000-2025 */
9/* */
10/* General declarations for Arccore. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
15#include "arccore/base/ArgumentException.h"
16#include "arccore/base/TraceInfo.h"
17#include "arccore/base/FatalErrorException.h"
18
19// We do not use these files directly but we include them to test
20// compilation. When tests are in place we can remove
21// these inclusions
25#include "arccore/base/Span.h"
26#include "arccore/base/Span2.h"
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31/*!
32 * \file Span.h
33 * \brief Types and functions associated with the classes SpanImpl, SmallSpan and Span.
34 */
35
36/*!
37 * \file Span2.h
38 * \brief Types and functions associated with the classes Span2Impl, Small2Span and Span2.
39 */
40
41/*!
42 * \file ArrayView.h
43 * \brief Types and functions associated with the classes ArrayView and ConstArrayView.
44 */
45
46/*!
47 * \file Array2View.h
48 * \brief Types and functions associated with the classes Array2View and ConstArray2View.
49 */
50
51/*!
52 * \file Array3View.h
53 * \brief Types and functions associated with the classes Array3View and ConstArray3View.
54 */
55
56/*!
57 * \file Array4View.h
58 * \brief Types and functions associated with the classes Array4View and ConstArray4View.
59 */
60
61/*---------------------------------------------------------------------------*/
62/*---------------------------------------------------------------------------*/
63
64namespace Arcane
65{
66
67/*---------------------------------------------------------------------------*/
68/*---------------------------------------------------------------------------*/
69
70//! Throws an 'ArgumentException'
71ARCCORE_BASE_EXPORT void impl::
72arccoreThrowTooBigInteger [[noreturn]] (std::size_t size)
73{
74 ARCCORE_THROW(ArgumentException, "value '{0}' too big for Array size", size);
75}
76
77//! Throws an 'ArgumentException'
78ARCCORE_BASE_EXPORT void impl::
79arccoreThrowTooBigInt64 [[noreturn]] (std::size_t size)
80{
81 ARCCORE_THROW(ArgumentException, "value '{0}' too big to fit in Int64", size);
82}
83
84ARCCORE_BASE_EXPORT void impl::
85arccoreThrowNegativeSize [[noreturn]] (Int64 size)
86{
87 ARCCORE_THROW(ArgumentException, "invalid negative value '{0}' for Array size", size);
88}
89
90/*---------------------------------------------------------------------------*/
91/*---------------------------------------------------------------------------*/
92
93void binaryWrite(std::ostream& ostr, const Span<const std::byte>& bytes)
94{
95 auto* ptr = reinterpret_cast<const char*>(bytes.data());
96 ostr.write(ptr, bytes.size());
97}
98
99/*---------------------------------------------------------------------------*/
100/*---------------------------------------------------------------------------*/
101
102void binaryRead(std::istream& istr, const Span<std::byte>& bytes)
103{
104 auto* ptr = reinterpret_cast<char*>(bytes.data());
105 istr.read(ptr, bytes.size());
106}
107
108/*---------------------------------------------------------------------------*/
109/*---------------------------------------------------------------------------*/
110
111void Impl::ExtentStorageBase::
112_throwBadSize(Int64 wanted_size, Int64 expected_size)
113{
114 ARCCORE_FATAL("Bad size value for fixed extent size={0} expected={1}", wanted_size, expected_size);
115}
116
117/*---------------------------------------------------------------------------*/
118/*---------------------------------------------------------------------------*/
119
120} // namespace Arcane
121
122/*---------------------------------------------------------------------------*/
123/*---------------------------------------------------------------------------*/
#define ARCCORE_FATAL(...)
Macro throwing a FatalErrorException.
#define ARCCORE_THROW(exception_class,...)
Macro to throw an exception with formatting.
Types and functions associated with the classes Span2Impl, Small2Span and Span2.
Types and functions associated with the classes SpanImpl, SmallSpan and Span.
Types and functions associated with the classes Array2View and ConstArray2View.
Types and functions associated with the classes Array3View and ConstArray3View.
Types and functions associated with the classes Array4View and ConstArray4View.
Types and functions associated with the classes ArrayView and ConstArrayView.
constexpr __host__ __device__ pointer data() const noexcept
Pointer to the start of the view.
Definition Span.h:539
constexpr __host__ __device__ SizeType size() const noexcept
Returns the size of the array.
Definition Span.h:327
View of an array of elements of type T.
Definition Span.h:635
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
void binaryRead(std::istream &istr, const Span< std::byte > &bytes)
Reads the content of bytes from the stream istr in binary format.
Definition ArrayView.cc:102
void binaryWrite(std::ostream &ostr, const Span< const std::byte > &bytes)
Writes the content of bytes to the stream ostr in binary format.
Definition ArrayView.cc:93