• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender / 1022567176

02 Oct 2023 07:50AM UTC coverage: 80.127% (+2.5%) from 77.645%
1022567176

push

gitlab-ci

kacf
chore: Centralize selection of `std::filesystem` library.

Signed-off-by: Kristian Amlie <kristian.amlie@northern.tech>

6447 of 8046 relevant lines covered (80.13%)

9912.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/common/expected.hpp
1
// Copyright 2023 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14

15
#ifndef MENDER_COMMON_EXPECTED_HPP
16
#define MENDER_COMMON_EXPECTED_HPP
17

18
#ifdef __cpp_lib_expected
19
#include <expected>
20
#else
21
#include <tl/expected.hpp>
22
#endif
23

24
#include <common/error.hpp>
25

26
#include <cassert>
27
#include <cstdint>
28
#include <string>
29
#include <vector>
30
#include <unordered_set>
31

32

33
namespace mender {
34
namespace common {
35
namespace expected {
36

37
using namespace std;
38

39
#ifdef __cpp_lib_expected
40
using std::expected;
41
using std::unexpected;
42
#else
43
using tl::expected;
44
template <typename V>
45
tl::unexpected<V> unexpected(V &&v) {
46
        return tl::make_unexpected(v);
47
}
48
template <typename V>
49
tl::unexpected<V> unexpected(V &v) {
50
        return tl::make_unexpected(v);
×
51
}
52
#endif
53

54
using ExpectedString = expected<string, error::Error>;
55
using ExpectedBytes = expected<vector<uint8_t>, error::Error>;
56
using ExpectedInt = expected<int, error::Error>;
57
using ExpectedInt64 = expected<int64_t, error::Error>;
58
using ExpectedDouble = expected<double, error::Error>;
59
using ExpectedBool = expected<bool, error::Error>;
60
using ExpectedSize = expected<size_t, error::Error>;
61
using ExpectedSize = expected<size_t, error::Error>;
62
using ExpectedBool = expected<bool, error::Error>;
63
using ExpectedLong = expected<long, error::Error>;
64
using ExpectedLongLong = expected<long long, error::Error>;
65
using ExpectedStringVector = expected<vector<string>, error::Error>;
66

67
template <typename T>
68
using ExpectedVector = expected<vector<T>, error::Error>;
69

70
template <typename T>
71
using ExpectedUnorderedSet = expected<unordered_set<T>, error::Error>;
72

73
} // namespace expected
74
} // namespace common
75
} // namespace mender
76

77
#endif // MENDER_COMMON_EXPECTED_HPP
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc