Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MemoryView.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/* MemoryView.cc (C) 2000-2025 */
9/* */
10/* Constant or mutable views on a memory area. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arccore/base/MemoryView.h"
15
16/*---------------------------------------------------------------------------*/
17/*---------------------------------------------------------------------------*/
18
19namespace Arcane
20{
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
26makeMutableMemoryView(void* ptr, Int32 datatype_size, Int64 nb_element)
27{
28 Span<std::byte> bytes(reinterpret_cast<std::byte*>(ptr), datatype_size * nb_element);
29 return { bytes, datatype_size, nb_element };
30}
31
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
34
36makeConstMemoryView(const void* ptr, Int32 datatype_size, Int64 nb_element)
37{
38 Span<const std::byte> bytes(reinterpret_cast<const std::byte*>(ptr), datatype_size * nb_element);
39 return { bytes, datatype_size, nb_element };
40}
41
42/*---------------------------------------------------------------------------*/
43/*---------------------------------------------------------------------------*/
44
45} // End namespace Arcane
46
47/*---------------------------------------------------------------------------*/
48/*---------------------------------------------------------------------------*/
Constant view on a contiguous memory region containing fixed-size elements.
constexpr SpanType bytes() const
View in byte form.
Mutable view on a contiguous memory region containing fixed-size elements.
constexpr SpanType bytes() const
View in byte form.
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 --
MutableMemoryView makeMutableMemoryView(void *ptr, Int32 datatype_size, Int64 nb_element)
Creates a mutable memory view.
Definition MemoryView.cc:26
std::int64_t Int64
Signed integer type of 64 bits.
ConstMemoryView makeConstMemoryView(const void *ptr, Int32 datatype_size, Int64 nb_element)
Creates a read-only memory view.
Definition MemoryView.cc:36
std::int32_t Int32
Signed integer type of 32 bits.