GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Noexcept was a lie! Add roadmap. · hmenke/cpp-patterns@d53e9bc

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • multi_array
    • example.cpp
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎multi_array/example.cpp‎

Copy file name to clipboardExpand all lines: multi_array/example.cpp
+18-6Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#include <cassert>
1+
// Copyright (c) 2018 Henri Menke. All rights reserved.
2+
23
#include <iostream>
34
#include <stdexcept>
45
#include <string>
5-
#include <tuple>
66
#include <type_traits>
77

88
#ifdef __CUDACC__
@@ -183,7 +183,7 @@ class multi_array {
183183
DEVICE_FUNC const_pointer data() const noexcept { return m_data; }
184184

185185
template <typename... Idx>
186-
DEVICE_FUNC CXX14_CONSTEXPR reference operator()(Idx... idx) noexcept {
186+
DEVICE_FUNC CXX14_CONSTEXPR reference operator()(Idx... idx) {
187187
static_assert(sizeof...(idx) == sizeof...(N), "dimension mismatch");
188188
static_assert(
189189
meta::all<std::is_convertible<Idx, size_type>::value...>::value,
@@ -196,7 +196,7 @@ class multi_array {
196196
}
197197

198198
template <typename... Idx>
199-
DEVICE_FUNC constexpr value_type operator()(Idx... idx) const noexcept {
199+
DEVICE_FUNC constexpr value_type operator()(Idx... idx) const {
200200
static_assert(sizeof...(idx) == sizeof...(N), "dimension mismatch");
201201
static_assert(
202202
meta::all<std::is_convertible<Idx, size_type>::value...>::value,
@@ -209,15 +209,15 @@ class multi_array {
209209
}
210210

211211
template <size_type... idx>
212-
DEVICE_FUNC CXX14_CONSTEXPR reference get() noexcept {
212+
DEVICE_FUNC CXX14_CONSTEXPR reference get() {
213213
static_assert(sizeof...(idx) == sizeof...(N), "dimension mismatch");
214214
static_assert(meta::all<size_less<idx, N>::value...>::value,
215215
"index out of bounds");
216216
return this->operator()(idx...);
217217
}
218218

219219
template <size_type... idx>
220-
DEVICE_FUNC constexpr value_type get() const noexcept {
220+
DEVICE_FUNC constexpr value_type get() const {
221221
static_assert(sizeof...(idx) == sizeof...(N), "dimension mismatch");
222222
static_assert(meta::all<size_less<idx, N>::value...>::value,
223223
"index out of bounds");
@@ -233,6 +233,18 @@ class multi_array {
233233
DEVICE_FUNC constexpr size_type size() const noexcept {
234234
return size_product<N...>::value;
235235
}
236+
237+
// Maybe add these member functions
238+
// - at
239+
// - (c,r,cr)begin, (c,r,cr)end
240+
// - front, back (how useful are those?)
241+
// Maybe add these operators
242+
// - operator==
243+
// - operator!=
244+
// - operator<
245+
// - operator<=
246+
// - operator>
247+
// - operator>=
236248
};
237249

238250
} // namespace math

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.