x037.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "xerror.h"
4 #include <array>
5 #include <iomanip>
6 #include <iostream>
7 
8 namespace nmx::apps::x037 {
9 
13 inline void ex1() {
14  try {
15  constexpr size_t N = 5;
16  std::array<double, N> a;
17  //fülle Feld
18  for (size_t idx = 0; idx < N; idx++) {
19  a[idx] = 0.2 * idx;
20  }
21  //schreibe Elemente auf dem Bildschirm
22  for (size_t idx = 0; idx < N + 2; idx++) {
23  //generiere mit Makro eine Nachricht (wenn Index unzulässig)
24  Check::error_if_not<std::out_of_range>(nmx_msgx(idx < N), idx < N);
25  std::cout << a[idx] << std::setw(5);
26  }
27  } catch (std::out_of_range err) {
28  std::cout << "\nerror:out of range\n" << err.what() << "\n";
29  }
30 }
31 } // namespace nmx::apps::x037
void ex1()
ex1 Fehlerbehandlung Beispielanwendung
Definition: x037.h:13
#define nmx_msgx(msg)
Definition: xerror.h:125