/src/node/deps/v8/include/v8-maybe.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright 2021 the V8 project authors. All rights reserved. |
2 | | // Use of this source code is governed by a BSD-style license that can be |
3 | | // found in the LICENSE file. |
4 | | |
5 | | #ifndef INCLUDE_V8_MAYBE_H_ |
6 | | #define INCLUDE_V8_MAYBE_H_ |
7 | | |
8 | | #include <type_traits> |
9 | | #include <utility> |
10 | | |
11 | | #include "v8-internal.h" // NOLINT(build/include_directory) |
12 | | #include "v8config.h" // NOLINT(build/include_directory) |
13 | | |
14 | | namespace v8 { |
15 | | |
16 | | namespace api_internal { |
17 | | // Called when ToChecked is called on an empty Maybe. |
18 | | V8_EXPORT void FromJustIsNothing(); |
19 | | } // namespace api_internal |
20 | | |
21 | | /** |
22 | | * A simple Maybe type, representing an object which may or may not have a |
23 | | * value, see https://hackage.haskell.org/package/base/docs/Data-Maybe.html. |
24 | | * |
25 | | * If an API method returns a Maybe<>, the API method can potentially fail |
26 | | * either because an exception is thrown, or because an exception is pending, |
27 | | * e.g. because a previous API call threw an exception that hasn't been caught |
28 | | * yet, or because a TerminateExecution exception was thrown. In that case, a |
29 | | * "Nothing" value is returned. |
30 | | */ |
31 | | template <class T> |
32 | | class Maybe { |
33 | | public: |
34 | 26.6M | V8_INLINE bool IsNothing() const { return !has_value_; } v8::Maybe<bool>::IsNothing() const Line | Count | Source | 34 | 26.6M | V8_INLINE bool IsNothing() const { return !has_value_; } |
Unexecuted instantiation: v8::Maybe<node::ExitCode>::IsNothing() const Unexecuted instantiation: v8::Maybe<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::IsNothing() const Unexecuted instantiation: v8::Maybe<int>::IsNothing() const Unexecuted instantiation: v8::Maybe<unsigned int>::IsNothing() const Unexecuted instantiation: v8::Maybe<double>::IsNothing() const Unexecuted instantiation: v8::Maybe<long>::IsNothing() const Unexecuted instantiation: v8::Maybe<unsigned long>::IsNothing() const Unexecuted instantiation: v8::Maybe<node::StreamPipe*>::IsNothing() const |
35 | 156M | V8_INLINE bool IsJust() const { return has_value_; } v8::Maybe<bool>::IsJust() const Line | Count | Source | 35 | 118M | V8_INLINE bool IsJust() const { return has_value_; } |
v8::Maybe<unsigned long>::IsJust() const Line | Count | Source | 35 | 33.7M | V8_INLINE bool IsJust() const { return has_value_; } |
Unexecuted instantiation: v8::Maybe<node::ExitCode>::IsJust() const Unexecuted instantiation: v8::Maybe<double>::IsJust() const v8::Maybe<unsigned int>::IsJust() const Line | Count | Source | 35 | 66.7k | V8_INLINE bool IsJust() const { return has_value_; } |
v8::Maybe<int>::IsJust() const Line | Count | Source | 35 | 708k | V8_INLINE bool IsJust() const { return has_value_; } |
v8::Maybe<long>::IsJust() const Line | Count | Source | 35 | 610k | V8_INLINE bool IsJust() const { return has_value_; } |
Unexecuted instantiation: v8::Maybe<v8::PropertyAttribute>::IsJust() const v8::Maybe<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::IsJust() const Line | Count | Source | 35 | 3.02M | V8_INLINE bool IsJust() const { return has_value_; } |
Unexecuted instantiation: v8::Maybe<std::__1::vector<node::BaseObjectPtrImpl<node::BaseObject, false>, std::__1::allocator<node::BaseObjectPtrImpl<node::BaseObject, false> > > >::IsJust() const v8::Maybe<node::crypto::PKEncodingType>::IsJust() const Line | Count | Source | 35 | 6 | V8_INLINE bool IsJust() const { return has_value_; } |
Unexecuted instantiation: v8::Maybe<ngtcp2_cc_algo>::IsJust() const Unexecuted instantiation: v8::Maybe<node::quic::Endpoint::Options>::IsJust() const Unexecuted instantiation: v8::Maybe<node::quic::Session::Options>::IsJust() const Unexecuted instantiation: v8::Maybe<node::quic::SessionTicket>::IsJust() const Unexecuted instantiation: v8::Maybe<node::quic::PreferredAddress::Policy>::IsJust() const Unexecuted instantiation: v8::Maybe<node::quic::TransportParams::Options>::IsJust() const Unexecuted instantiation: v8::Maybe<node::quic::TLSContext::Options>::IsJust() const Unexecuted instantiation: v8::Maybe<node::quic::Session::Application_Options>::IsJust() const Unexecuted instantiation: v8::Maybe<std::__1::shared_ptr<node::DataQueue> >::IsJust() const |
36 | | |
37 | | /** |
38 | | * An alias for |FromJust|. Will crash if the Maybe<> is nothing. |
39 | | */ |
40 | 269k | V8_INLINE T ToChecked() const { return FromJust(); } v8::Maybe<bool>::ToChecked() const Line | Count | Source | 40 | 269k | V8_INLINE T ToChecked() const { return FromJust(); } |
Unexecuted instantiation: v8::Maybe<int>::ToChecked() const Unexecuted instantiation: v8::Maybe<unsigned int>::ToChecked() const v8::Maybe<node::crypto::PKEncodingType>::ToChecked() const Line | Count | Source | 40 | 6 | V8_INLINE T ToChecked() const { return FromJust(); } |
v8::Maybe<long>::ToChecked() const Line | Count | Source | 40 | 16 | V8_INLINE T ToChecked() const { return FromJust(); } |
|
41 | | |
42 | | /** |
43 | | * Short-hand for ToChecked(), which doesn't return a value. To be used, where |
44 | | * the actual value of the Maybe is not needed like Object::Set. |
45 | | */ |
46 | 102M | V8_INLINE void Check() const { |
47 | 102M | if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing(); |
48 | 102M | } |
49 | | |
50 | | /** |
51 | | * Converts this Maybe<> to a value of type T. If this Maybe<> is |
52 | | * nothing (empty), |false| is returned and |out| is left untouched. |
53 | | */ |
54 | 18.6M | V8_WARN_UNUSED_RESULT V8_INLINE bool To(T* out) const { |
55 | 18.6M | if (V8_LIKELY(IsJust())) *out = value_; |
56 | 18.6M | return IsJust(); |
57 | 18.6M | } v8::Maybe<unsigned long>::To(unsigned long*) const Line | Count | Source | 54 | 16.8M | V8_WARN_UNUSED_RESULT V8_INLINE bool To(T* out) const { | 55 | 16.8M | if (V8_LIKELY(IsJust())) *out = value_; | 56 | 16.8M | return IsJust(); | 57 | 16.8M | } |
v8::Maybe<unsigned int>::To(unsigned int*) const Line | Count | Source | 54 | 32.9k | V8_WARN_UNUSED_RESULT V8_INLINE bool To(T* out) const { | 55 | 32.9k | if (V8_LIKELY(IsJust())) *out = value_; | 56 | 32.9k | return IsJust(); | 57 | 32.9k | } |
v8::Maybe<int>::To(int*) const Line | Count | Source | 54 | 271k | V8_WARN_UNUSED_RESULT V8_INLINE bool To(T* out) const { | 55 | 271k | if (V8_LIKELY(IsJust())) *out = value_; | 56 | 271k | return IsJust(); | 57 | 271k | } |
v8::Maybe<long>::To(long*) const Line | Count | Source | 54 | 304k | V8_WARN_UNUSED_RESULT V8_INLINE bool To(T* out) const { | 55 | 304k | if (V8_LIKELY(IsJust())) *out = value_; | 56 | 304k | return IsJust(); | 57 | 304k | } |
Unexecuted instantiation: v8::Maybe<v8::PropertyAttribute>::To(v8::PropertyAttribute*) const v8::Maybe<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::To(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) const Line | Count | Source | 54 | 1.19M | V8_WARN_UNUSED_RESULT V8_INLINE bool To(T* out) const { | 55 | 1.19M | if (V8_LIKELY(IsJust())) *out = value_; | 56 | 1.19M | return IsJust(); | 57 | 1.19M | } |
Unexecuted instantiation: v8::Maybe<bool>::To(bool*) const Unexecuted instantiation: v8::Maybe<std::__1::vector<node::BaseObjectPtrImpl<node::BaseObject, false>, std::__1::allocator<node::BaseObjectPtrImpl<node::BaseObject, false> > > >::To(std::__1::vector<node::BaseObjectPtrImpl<node::BaseObject, false>, std::__1::allocator<node::BaseObjectPtrImpl<node::BaseObject, false> > >*) const Unexecuted instantiation: v8::Maybe<double>::To(double*) const Unexecuted instantiation: v8::Maybe<ngtcp2_cc_algo>::To(ngtcp2_cc_algo*) const Unexecuted instantiation: v8::Maybe<node::quic::Endpoint::Options>::To(node::quic::Endpoint::Options*) const Unexecuted instantiation: v8::Maybe<node::quic::Session::Options>::To(node::quic::Session::Options*) const Unexecuted instantiation: v8::Maybe<node::quic::SessionTicket>::To(node::quic::SessionTicket*) const Unexecuted instantiation: v8::Maybe<node::quic::PreferredAddress::Policy>::To(node::quic::PreferredAddress::Policy*) const Unexecuted instantiation: v8::Maybe<node::quic::TransportParams::Options>::To(node::quic::TransportParams::Options*) const Unexecuted instantiation: v8::Maybe<node::quic::TLSContext::Options>::To(node::quic::TLSContext::Options*) const Unexecuted instantiation: v8::Maybe<node::quic::Session::Application_Options>::To(node::quic::Session::Application_Options*) const Unexecuted instantiation: v8::Maybe<std::__1::shared_ptr<node::DataQueue> >::To(std::__1::shared_ptr<node::DataQueue>*) const |
58 | | |
59 | | /** |
60 | | * Converts this Maybe<> to a value of type T. If this Maybe<> is |
61 | | * nothing (empty), V8 will crash the process. |
62 | | */ |
63 | 574k | V8_INLINE T FromJust() const& { |
64 | 574k | if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing(); |
65 | 574k | return value_; |
66 | 574k | } Unexecuted instantiation: v8::Maybe<node::ExitCode>::FromJust() const & v8::Maybe<bool>::FromJust() const & Line | Count | Source | 63 | 574k | V8_INLINE T FromJust() const& { | 64 | 574k | if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing(); | 65 | 574k | return value_; | 66 | 574k | } |
Unexecuted instantiation: v8::Maybe<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::FromJust() const & Unexecuted instantiation: v8::Maybe<int>::FromJust() const & Unexecuted instantiation: v8::Maybe<unsigned int>::FromJust() const & Unexecuted instantiation: v8::Maybe<double>::FromJust() const & v8::Maybe<long>::FromJust() const & Line | Count | Source | 63 | 16 | V8_INLINE T FromJust() const& { | 64 | 16 | if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing(); | 65 | 16 | return value_; | 66 | 16 | } |
Unexecuted instantiation: v8::Maybe<unsigned long>::FromJust() const & v8::Maybe<node::crypto::PKEncodingType>::FromJust() const & Line | Count | Source | 63 | 6 | V8_INLINE T FromJust() const& { | 64 | 6 | if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing(); | 65 | 6 | return value_; | 66 | 6 | } |
|
67 | | |
68 | | /** |
69 | | * Converts this Maybe<> to a value of type T. If this Maybe<> is |
70 | | * nothing (empty), V8 will crash the process. |
71 | | */ |
72 | 15.9M | V8_INLINE T FromJust() && { |
73 | 15.9M | if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing(); |
74 | 15.9M | return std::move(value_); |
75 | 15.9M | } Unexecuted instantiation: v8::Maybe<double>::FromJust() && v8::Maybe<bool>::FromJust() && Line | Count | Source | 72 | 15.7M | V8_INLINE T FromJust() && { | 73 | 15.7M | if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing(); | 74 | 15.7M | return std::move(value_); | 75 | 15.7M | } |
v8::Maybe<unsigned int>::FromJust() && Line | Count | Source | 72 | 3 | V8_INLINE T FromJust() && { | 73 | 3 | if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing(); | 74 | 3 | return std::move(value_); | 75 | 3 | } |
v8::Maybe<int>::FromJust() && Line | Count | Source | 72 | 164k | V8_INLINE T FromJust() && { | 73 | 164k | if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing(); | 74 | 164k | return std::move(value_); | 75 | 164k | } |
v8::Maybe<long>::FromJust() && Line | Count | Source | 72 | 1.98k | V8_INLINE T FromJust() && { | 73 | 1.98k | if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing(); | 74 | 1.98k | return std::move(value_); | 75 | 1.98k | } |
|
76 | | |
77 | | /** |
78 | | * Converts this Maybe<> to a value of type T, using a default value if this |
79 | | * Maybe<> is nothing (empty). |
80 | | */ |
81 | 93.9M | V8_INLINE T FromMaybe(const T& default_value) const { |
82 | 93.9M | return has_value_ ? value_ : default_value; |
83 | 93.9M | } Unexecuted instantiation: v8::Maybe<node::ExitCode>::FromMaybe(node::ExitCode const&) const v8::Maybe<bool>::FromMaybe(bool const&) const Line | Count | Source | 81 | 93.4M | V8_INLINE T FromMaybe(const T& default_value) const { | 82 | 93.4M | return has_value_ ? value_ : default_value; | 83 | 93.4M | } |
v8::Maybe<int>::FromMaybe(int const&) const Line | Count | Source | 81 | 329k | V8_INLINE T FromMaybe(const T& default_value) const { | 82 | 329k | return has_value_ ? value_ : default_value; | 83 | 329k | } |
v8::Maybe<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::FromMaybe(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const Line | Count | Source | 81 | 134k | V8_INLINE T FromMaybe(const T& default_value) const { | 82 | 134k | return has_value_ ? value_ : default_value; | 83 | 134k | } |
v8::Maybe<long>::FromMaybe(long const&) const Line | Count | Source | 81 | 847 | V8_INLINE T FromMaybe(const T& default_value) const { | 82 | 847 | return has_value_ ? value_ : default_value; | 83 | 847 | } |
Unexecuted instantiation: v8::Maybe<unsigned long>::FromMaybe(unsigned long const&) const |
84 | | |
85 | | V8_INLINE bool operator==(const Maybe& other) const { |
86 | | return (IsJust() == other.IsJust()) && |
87 | | (!IsJust() || FromJust() == other.FromJust()); |
88 | | } |
89 | | |
90 | | V8_INLINE bool operator!=(const Maybe& other) const { |
91 | | return !operator==(other); |
92 | | } |
93 | | |
94 | | private: |
95 | 1.83M | Maybe() : has_value_(false) {} Unexecuted instantiation: v8::Maybe<bool>::Maybe() Unexecuted instantiation: v8::Maybe<node::ExitCode>::Maybe() Line | Count | Source | 95 | 8 | Maybe() : has_value_(false) {} |
v8::Maybe<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::Maybe() Line | Count | Source | 95 | 1.82M | Maybe() : has_value_(false) {} |
Unexecuted instantiation: v8::Maybe<std::__1::vector<node::BaseObjectPtrImpl<node::BaseObject, false>, std::__1::allocator<node::BaseObjectPtrImpl<node::BaseObject, false> > > >::Maybe() v8::Maybe<unsigned int>::Maybe() Line | Count | Source | 95 | 858 | Maybe() : has_value_(false) {} |
Unexecuted instantiation: v8::Maybe<node::StreamPipe*>::Maybe() Unexecuted instantiation: v8::Maybe<unsigned long>::Maybe() v8::Maybe<node::crypto::PKEncodingType>::Maybe() Line | Count | Source | 95 | 2.61k | Maybe() : has_value_(false) {} |
Unexecuted instantiation: v8::Maybe<node::quic::Endpoint::Options>::Maybe() Unexecuted instantiation: v8::Maybe<ngtcp2_cc_algo>::Maybe() Unexecuted instantiation: v8::Maybe<node::quic::Session::Options>::Maybe() Unexecuted instantiation: v8::Maybe<node::quic::SessionTicket>::Maybe() Unexecuted instantiation: v8::Maybe<std::__1::shared_ptr<node::DataQueue> >::Maybe() Unexecuted instantiation: v8::Maybe<node::quic::TLSContext::Options>::Maybe() Unexecuted instantiation: v8::Maybe<node::quic::TransportParams::Options>::Maybe() Unexecuted instantiation: v8::Maybe<node::quic::Session::Application_Options>::Maybe() Unexecuted instantiation: v8::Maybe<node::quic::PreferredAddress::Policy>::Maybe() |
96 | 16.8M | explicit Maybe(const T& t) : has_value_(true), value_(t) {} Unexecuted instantiation: v8::Maybe<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::Maybe(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: v8::Maybe<unsigned int>::Maybe(unsigned int const&) Unexecuted instantiation: v8::Maybe<std::__1::vector<node::BaseObjectPtrImpl<node::BaseObject, false>, std::__1::allocator<node::BaseObjectPtrImpl<node::BaseObject, false> > > >::Maybe(std::__1::vector<node::BaseObjectPtrImpl<node::BaseObject, false>, std::__1::allocator<node::BaseObjectPtrImpl<node::BaseObject, false> > > const&) Unexecuted instantiation: v8::Maybe<double>::Maybe(double const&) Unexecuted instantiation: v8::Maybe<int>::Maybe(int const&) v8::Maybe<unsigned long>::Maybe(unsigned long const&) Line | Count | Source | 96 | 16.8M | explicit Maybe(const T& t) : has_value_(true), value_(t) {} |
Unexecuted instantiation: v8::Maybe<node::quic::Endpoint::Options>::Maybe(node::quic::Endpoint::Options const&) Unexecuted instantiation: v8::Maybe<node::quic::Session::Options>::Maybe(node::quic::Session::Options const&) Unexecuted instantiation: v8::Maybe<node::quic::TLSContext::Options>::Maybe(node::quic::TLSContext::Options const&) Unexecuted instantiation: v8::Maybe<node::quic::TransportParams::Options>::Maybe(node::quic::TransportParams::Options const&) Unexecuted instantiation: v8::Maybe<node::quic::Session::Application_Options>::Maybe(node::quic::Session::Application_Options const&) |
97 | 992k | explicit Maybe(T&& t) : has_value_(true), value_(std::move(t)) {} v8::Maybe<bool>::Maybe(bool&&) Line | Count | Source | 97 | 853k | explicit Maybe(T&& t) : has_value_(true), value_(std::move(t)) {} |
Unexecuted instantiation: v8::Maybe<node::ExitCode>::Maybe(node::ExitCode&&) v8::Maybe<int>::Maybe(int&&) Line | Count | Source | 97 | 1 | explicit Maybe(T&& t) : has_value_(true), value_(std::move(t)) {} |
Unexecuted instantiation: v8::Maybe<std::__1::vector<node::BaseObjectPtrImpl<node::BaseObject, false>, std::__1::allocator<node::BaseObjectPtrImpl<node::BaseObject, false> > > >::Maybe(std::__1::vector<node::BaseObjectPtrImpl<node::BaseObject, false>, std::__1::allocator<node::BaseObjectPtrImpl<node::BaseObject, false> > >&&) v8::Maybe<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::Maybe(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&) Line | Count | Source | 97 | 134k | explicit Maybe(T&& t) : has_value_(true), value_(std::move(t)) {} |
Unexecuted instantiation: v8::Maybe<unsigned int>::Maybe(unsigned int&&) Unexecuted instantiation: v8::Maybe<node::StreamPipe*>::Maybe(node::StreamPipe*&&) v8::Maybe<unsigned long>::Maybe(unsigned long&&) Line | Count | Source | 97 | 4.87k | explicit Maybe(T&& t) : has_value_(true), value_(std::move(t)) {} |
v8::Maybe<node::crypto::PKEncodingType>::Maybe(node::crypto::PKEncodingType&&) Line | Count | Source | 97 | 4 | explicit Maybe(T&& t) : has_value_(true), value_(std::move(t)) {} |
Unexecuted instantiation: v8::Maybe<ngtcp2_cc_algo>::Maybe(ngtcp2_cc_algo&&) Unexecuted instantiation: v8::Maybe<node::quic::SessionTicket>::Maybe(node::quic::SessionTicket&&) Unexecuted instantiation: v8::Maybe<std::__1::shared_ptr<node::DataQueue> >::Maybe(std::__1::shared_ptr<node::DataQueue>&&) Unexecuted instantiation: v8::Maybe<node::quic::PreferredAddress::Policy>::Maybe(node::quic::PreferredAddress::Policy&&) |
98 | | |
99 | | bool has_value_; |
100 | | T value_; |
101 | | |
102 | | template <class U> |
103 | | friend Maybe<U> Nothing(); |
104 | | template <class U> |
105 | | friend Maybe<U> Just(const U& u); |
106 | | template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*> |
107 | | friend Maybe<U> Just(U&& u); |
108 | | }; |
109 | | |
110 | | template <class T> |
111 | 1.83M | inline Maybe<T> Nothing() { |
112 | 1.83M | return Maybe<T>(); |
113 | 1.83M | } Unexecuted instantiation: v8::Maybe<bool> v8::Nothing<bool>() Unexecuted instantiation: v8::Maybe<node::ExitCode> v8::Nothing<node::ExitCode>() v8::Maybe<int> v8::Nothing<int>() Line | Count | Source | 111 | 8 | inline Maybe<T> Nothing() { | 112 | 8 | return Maybe<T>(); | 113 | 8 | } |
Unexecuted instantiation: v8::Maybe<void> v8::Nothing<void>() v8::Maybe<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > v8::Nothing<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >() Line | Count | Source | 111 | 1.82M | inline Maybe<T> Nothing() { | 112 | 1.82M | return Maybe<T>(); | 113 | 1.82M | } |
Unexecuted instantiation: v8::Maybe<std::__1::vector<node::BaseObjectPtrImpl<node::BaseObject, false>, std::__1::allocator<node::BaseObjectPtrImpl<node::BaseObject, false> > > > v8::Nothing<std::__1::vector<node::BaseObjectPtrImpl<node::BaseObject, false>, std::__1::allocator<node::BaseObjectPtrImpl<node::BaseObject, false> > > >() v8::Maybe<unsigned int> v8::Nothing<unsigned int>() Line | Count | Source | 111 | 858 | inline Maybe<T> Nothing() { | 112 | 858 | return Maybe<T>(); | 113 | 858 | } |
Unexecuted instantiation: v8::Maybe<node::StreamPipe*> v8::Nothing<node::StreamPipe*>() Unexecuted instantiation: v8::Maybe<unsigned long> v8::Nothing<unsigned long>() v8::Maybe<node::crypto::PKEncodingType> v8::Nothing<node::crypto::PKEncodingType>() Line | Count | Source | 111 | 2.61k | inline Maybe<T> Nothing() { | 112 | 2.61k | return Maybe<T>(); | 113 | 2.61k | } |
Unexecuted instantiation: v8::Maybe<node::quic::Endpoint::Options> v8::Nothing<node::quic::Endpoint::Options>() Unexecuted instantiation: v8::Maybe<ngtcp2_cc_algo> v8::Nothing<ngtcp2_cc_algo>() Unexecuted instantiation: v8::Maybe<node::quic::Session::Options> v8::Nothing<node::quic::Session::Options>() Unexecuted instantiation: v8::Maybe<node::quic::SessionTicket> v8::Nothing<node::quic::SessionTicket>() Unexecuted instantiation: v8::Maybe<std::__1::shared_ptr<node::DataQueue> > v8::Nothing<std::__1::shared_ptr<node::DataQueue> >() Unexecuted instantiation: v8::Maybe<node::quic::TLSContext::Options> v8::Nothing<node::quic::TLSContext::Options>() Unexecuted instantiation: v8::Maybe<node::quic::TransportParams::Options> v8::Nothing<node::quic::TransportParams::Options>() Unexecuted instantiation: v8::Maybe<node::quic::Session::Application_Options> v8::Nothing<node::quic::Session::Application_Options>() Unexecuted instantiation: v8::Maybe<node::quic::PreferredAddress::Policy> v8::Nothing<node::quic::PreferredAddress::Policy>() |
114 | | |
115 | | template <class T> |
116 | 16.8M | inline Maybe<T> Just(const T& t) { |
117 | 16.8M | return Maybe<T>(t); |
118 | 16.8M | } Unexecuted instantiation: v8::Maybe<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > v8::Just<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: v8::Maybe<unsigned int> v8::Just<unsigned int>(unsigned int const&) Unexecuted instantiation: v8::Maybe<std::__1::vector<node::BaseObjectPtrImpl<node::BaseObject, false>, std::__1::allocator<node::BaseObjectPtrImpl<node::BaseObject, false> > > > v8::Just<std::__1::vector<node::BaseObjectPtrImpl<node::BaseObject, false>, std::__1::allocator<node::BaseObjectPtrImpl<node::BaseObject, false> > > >(std::__1::vector<node::BaseObjectPtrImpl<node::BaseObject, false>, std::__1::allocator<node::BaseObjectPtrImpl<node::BaseObject, false> > > const&) Unexecuted instantiation: v8::Maybe<double> v8::Just<double>(double const&) Unexecuted instantiation: v8::Maybe<int> v8::Just<int>(int const&) v8::Maybe<unsigned long> v8::Just<unsigned long>(unsigned long const&) Line | Count | Source | 116 | 16.8M | inline Maybe<T> Just(const T& t) { | 117 | 16.8M | return Maybe<T>(t); | 118 | 16.8M | } |
Unexecuted instantiation: v8::Maybe<node::quic::Endpoint::Options> v8::Just<node::quic::Endpoint::Options>(node::quic::Endpoint::Options const&) Unexecuted instantiation: v8::Maybe<node::quic::Session::Options> v8::Just<node::quic::Session::Options>(node::quic::Session::Options const&) Unexecuted instantiation: v8::Maybe<node::quic::TLSContext::Options> v8::Just<node::quic::TLSContext::Options>(node::quic::TLSContext::Options const&) Unexecuted instantiation: v8::Maybe<node::quic::TransportParams::Options> v8::Just<node::quic::TransportParams::Options>(node::quic::TransportParams::Options const&) Unexecuted instantiation: v8::Maybe<node::quic::Session::Application_Options> v8::Just<node::quic::Session::Application_Options>(node::quic::Session::Application_Options const&) |
119 | | |
120 | | // Don't use forwarding references here but instead use two overloads. |
121 | | // Forwarding references only work when type deduction takes place, which is not |
122 | | // the case for callsites such as Just<Type>(t). |
123 | | template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr> |
124 | 992k | inline Maybe<T> Just(T&& t) { |
125 | 992k | return Maybe<T>(std::move(t)); |
126 | 992k | } _ZN2v84JustIbTnPNSt3__19enable_ifIXntsr3stdE21is_lvalue_reference_vIT_EEvE4typeELPv0EEENS_5MaybeIS3_EEOS3_ Line | Count | Source | 124 | 853k | inline Maybe<T> Just(T&& t) { | 125 | 853k | return Maybe<T>(std::move(t)); | 126 | 853k | } |
Unexecuted instantiation: _ZN2v84JustIN4node8ExitCodeETnPNSt3__19enable_ifIXntsr3stdE21is_lvalue_reference_vIT_EEvE4typeELPv0EEENS_5MaybeIS5_EEOS5_ _ZN2v84JustIiTnPNSt3__19enable_ifIXntsr3stdE21is_lvalue_reference_vIT_EEvE4typeELPv0EEENS_5MaybeIS3_EEOS3_ Line | Count | Source | 124 | 1 | inline Maybe<T> Just(T&& t) { | 125 | 1 | return Maybe<T>(std::move(t)); | 126 | 1 | } |
Unexecuted instantiation: _ZN2v84JustINSt3__16vectorIN4node17BaseObjectPtrImplINS3_10BaseObjectELb0EEENS1_9allocatorIS6_EEEETnPNS1_9enable_ifIXntsr3stdE21is_lvalue_reference_vIT_EEvE4typeELPv0EEENS_5MaybeISB_EEOSB_ _ZN2v84JustINSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEETnPNS1_9enable_ifIXntsr3stdE21is_lvalue_reference_vIT_EEvE4typeELPv0EEENS_5MaybeIS9_EEOS9_ Line | Count | Source | 124 | 134k | inline Maybe<T> Just(T&& t) { | 125 | 134k | return Maybe<T>(std::move(t)); | 126 | 134k | } |
Unexecuted instantiation: _ZN2v84JustIjTnPNSt3__19enable_ifIXntsr3stdE21is_lvalue_reference_vIT_EEvE4typeELPv0EEENS_5MaybeIS3_EEOS3_ Unexecuted instantiation: _ZN2v84JustIPN4node10StreamPipeETnPNSt3__19enable_ifIXntsr3stdE21is_lvalue_reference_vIT_EEvE4typeELPv0EEENS_5MaybeIS6_EEOS6_ _ZN2v84JustImTnPNSt3__19enable_ifIXntsr3stdE21is_lvalue_reference_vIT_EEvE4typeELPv0EEENS_5MaybeIS3_EEOS3_ Line | Count | Source | 124 | 4.87k | inline Maybe<T> Just(T&& t) { | 125 | 4.87k | return Maybe<T>(std::move(t)); | 126 | 4.87k | } |
_ZN2v84JustIN4node6crypto14PKEncodingTypeETnPNSt3__19enable_ifIXntsr3stdE21is_lvalue_reference_vIT_EEvE4typeELPv0EEENS_5MaybeIS6_EEOS6_ Line | Count | Source | 124 | 4 | inline Maybe<T> Just(T&& t) { | 125 | 4 | return Maybe<T>(std::move(t)); | 126 | 4 | } |
Unexecuted instantiation: _ZN2v84JustI14ngtcp2_cc_algoTnPNSt3__19enable_ifIXntsr3stdE21is_lvalue_reference_vIT_EEvE4typeELPv0EEENS_5MaybeIS4_EEOS4_ Unexecuted instantiation: _ZN2v84JustIN4node4quic13SessionTicketETnPNSt3__19enable_ifIXntsr3stdE21is_lvalue_reference_vIT_EEvE4typeELPv0EEENS_5MaybeIS6_EEOS6_ Unexecuted instantiation: _ZN2v84JustINSt3__110shared_ptrIN4node9DataQueueEEETnPNS1_9enable_ifIXntsr3stdE21is_lvalue_reference_vIT_EEvE4typeELPv0EEENS_5MaybeIS7_EEOS7_ Unexecuted instantiation: _ZN2v84JustIN4node4quic16PreferredAddress6PolicyETnPNSt3__19enable_ifIXntsr3stdE21is_lvalue_reference_vIT_EEvE4typeELPv0EEENS_5MaybeIS7_EEOS7_ |
127 | | |
128 | | // A template specialization of Maybe<T> for the case of T = void. |
129 | | template <> |
130 | | class Maybe<void> { |
131 | | public: |
132 | 6.75k | V8_INLINE bool IsNothing() const { return !is_valid_; } |
133 | 0 | V8_INLINE bool IsJust() const { return is_valid_; } |
134 | | |
135 | 0 | V8_INLINE bool operator==(const Maybe& other) const { |
136 | 0 | return IsJust() == other.IsJust(); |
137 | 0 | } |
138 | | |
139 | 0 | V8_INLINE bool operator!=(const Maybe& other) const { |
140 | 0 | return !operator==(other); |
141 | 0 | } |
142 | | |
143 | | private: |
144 | | struct JustTag {}; |
145 | | |
146 | 0 | Maybe() : is_valid_(false) {} |
147 | 6.75k | explicit Maybe(JustTag) : is_valid_(true) {} |
148 | | |
149 | | bool is_valid_; |
150 | | |
151 | | template <class U> |
152 | | friend Maybe<U> Nothing(); |
153 | | friend Maybe<void> JustVoid(); |
154 | | }; |
155 | | |
156 | 6.75k | inline Maybe<void> JustVoid() { return Maybe<void>(Maybe<void>::JustTag()); } |
157 | | |
158 | | } // namespace v8 |
159 | | |
160 | | #endif // INCLUDE_V8_MAYBE_H_ |