TRIQS/nda
2.0.0
Multi-dimensional array library for C++
Toggle main menu visibility
Loading...
Searching...
No Matches
accessors.hpp
Go to the documentation of this file.
1
// Copyright (c) 2019--present, The Simons Foundation
2
// This file is part of TRIQS/nda and is licensed under the Apache License, Version 2.0.
3
// SPDX-License-Identifier: Apache-2.0
4
// See LICENSE in the root of this distribution for details.
5
10
11
#pragma once
12
13
#include "
./macros.hpp
"
14
15
#include <cstddef>
16
17
namespace
nda {
18
23
25
struct
default_accessor
{
30
template
<
typename
T>
31
struct
accessor
{
33
using
element_type
= T;
34
36
using
pointer
= T *;
37
39
using
reference
= T &;
40
48
FORCEINLINE
static
reference
access
(
pointer
p, std::ptrdiff_t i)
noexcept
{
49
EXPECTS(p !=
nullptr
);
50
return
p[i];
51
}
52
60
FORCEINLINE
static
T *
offset
(
pointer
p, std::ptrdiff_t i)
noexcept
{
return
p + i; }
61
};
62
};
63
65
struct
no_alias_accessor
{
70
template
<
typename
T>
71
struct
accessor
{
73
using
element_type
= T;
74
76
using
pointer
= T *__restrict;
77
79
using
reference
= T &;
80
88
FORCEINLINE
static
reference
access
(
pointer
p, std::ptrdiff_t i)
noexcept
{
return
p[i]; }
89
97
FORCEINLINE
static
T *
offset
(
pointer
p, std::ptrdiff_t i)
noexcept
{
return
p + i; }
98
};
99
};
100
102
103
}
// namespace nda
macros.hpp
Macros used in the nda library.
nda::default_accessor::accessor
Accessor type of the nda::default_accessor.
Definition
accessors.hpp:31
nda::default_accessor::accessor::offset
static __inline__ T * offset(pointer p, std::ptrdiff_t i) noexcept
Offset the pointer by a certain number of elements.
Definition
accessors.hpp:60
nda::default_accessor::accessor::pointer
T * pointer
Pointer type to the data.
Definition
accessors.hpp:36
nda::default_accessor::accessor::element_type
T element_type
Value type of the data.
Definition
accessors.hpp:33
nda::default_accessor::accessor::reference
T & reference
Reference type to the data.
Definition
accessors.hpp:39
nda::default_accessor::accessor::access
static __inline__ reference access(pointer p, std::ptrdiff_t i) noexcept
Access a specific element of the data.
Definition
accessors.hpp:48
nda::default_accessor
Default accessor for various array and view types.
Definition
accessors.hpp:25
nda::no_alias_accessor::accessor
Accessor type of the nda::no_alias_accessor.
Definition
accessors.hpp:71
nda::no_alias_accessor::accessor::access
static __inline__ reference access(pointer p, std::ptrdiff_t i) noexcept
Access a specific element of the data.
Definition
accessors.hpp:88
nda::no_alias_accessor::accessor::reference
T & reference
Reference type to the data.
Definition
accessors.hpp:79
nda::no_alias_accessor::accessor::element_type
T element_type
Value type of the data.
Definition
accessors.hpp:73
nda::no_alias_accessor::accessor::offset
static __inline__ T * offset(pointer p, std::ptrdiff_t i) noexcept
Offset the pointer by a certain number of elements.
Definition
accessors.hpp:97
nda::no_alias_accessor::accessor::pointer
T *__restrict pointer
Restricted pointer type to the data.
Definition
accessors.hpp:76
nda::no_alias_accessor
Accessor for array and view types with no aliasing.
Definition
accessors.hpp:65
nda
accessors.hpp
Generated by
1.17.0