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

realm / realm-core / 2457

01 Jul 2024 04:59PM UTC coverage: 90.986% (-0.02%) from 91.001%
2457

push

Evergreen

web-flow
Merge pull request #7796 from realm/tg/upload-completion

RCORE-2160 Make upload completion reporting multiprocess-compatible

102288 of 180462 branches covered (56.68%)

112 of 117 new or added lines in 8 files covered. (95.73%)

90 existing lines in 17 files now uncovered.

215133 of 236446 relevant lines covered (90.99%)

5720057.08 hits per line

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

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

19
#pragma once
20
#ifndef REALM_UTIL_OPTIONAL_HPP
21
#define REALM_UTIL_OPTIONAL_HPP
22

23
#include <optional>
24
#include <ostream>
25

26
namespace realm {
27
namespace util {
28

29
template <class T>
30
using Optional = std::optional<T>;
31
using None = std::nullopt_t;
32

33
template <class T, class... Args>
34
Optional<T> some(Args&&... args)
35
{
123,158,620✔
36
    return std::make_optional<T>(std::forward<Args>(args)...);
123,158,620✔
37
}
123,158,620✔
38

39
using std::make_optional;
40

41
constexpr auto none = std::nullopt;
42

43
template <class T>
44
struct RemoveOptional {
45
    using type = T;
46
};
47
template <class T>
48
struct RemoveOptional<Optional<T>> {
49
    using type = typename RemoveOptional<T>::type; // Remove recursively
50
};
51

52
/**
53
 * Writes a T to an ostream, with special handling if T is a std::optional.
54
 *
55
 * This function supports both optional and non-optional Ts, so that callers don't need to do their own dispatch.
56
 */
57
template <class T>
58
std::ostream& stream_possible_optional(std::ostream& os, const T& rhs)
59
{
1,038,058✔
60
    return os << rhs;
1,038,058✔
61
}
1,038,058✔
62
template <class T>
63
std::ostream& stream_possible_optional(std::ostream& os, const std::optional<T>& rhs)
UNCOV
64
{
×
UNCOV
65
    if (rhs) {
×
UNCOV
66
        os << "some(" << *rhs << ")";
×
UNCOV
67
    }
×
68
    else {
×
69
        os << "none";
×
70
    }
×
UNCOV
71
    return os;
×
UNCOV
72
}
×
73

74
} // namespace util
75

76
using util::none;
77

78
} // namespace realm
79

80
#endif // REALM_UTIL_OPTIONAL_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

© 2026 Coveralls, Inc