-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA16-2-2.cpp
More file actions
42 lines (36 loc) · 804 Bytes
/
A16-2-2.cpp
File metadata and controls
42 lines (36 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Rule: A16-2-2
// Source line: 27625
// Original file: A16-2-2.cpp
// $Id: A16-2-2.cpp 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $
#include <algorithm> // Non-compliant - nothing from algorithm header file is
used
#include <array>
// Non-compliant - nothing from array header file is used
#include <cstdint>
// Compliant - std::int32_t, std::uint8_t are used
#include <iostream>
// Compliant - cout is used
#include <stdexcept> // Compliant - out_of_range is used
#include <vector>
// Compliant - vector is used
void Fn1() noexcept
{
std::int32_t x = 0;
// ...
std::uint8_t y = 0;
// ...
}
void Fn2() noexcept(false)
{
try
{
std::vector<std::int32_t> v;
// ...
std::uint8_t idx = 3;
std::int32_t value = v.at(idx);
}
catch (std::out_of_range& e)
{
std::cout << e.what() << ’\n’;
}
}