LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
optional.hpp
Go to the documentation of this file.
1/* Copyright 2021 - 2025 R. Thomas
2 * Copyright 2021 - 2025 Quarkslab
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef LIEF_OPTIONAL_H
17#define LIEF_OPTIONAL_H
18#include "LIEF/errors.hpp"
19
20namespace LIEF {
21
22template<class T>
23class optional : public result<T> {
24 public:
25 using result<T>::result;
26
28 result<T>(tl::make_unexpected(lief_errors::not_found))
29 {}
30
31 void reset() noexcept {
32 new (this) optional();
33 }
34};
35
36inline tl::unexpected<lief_errors> nullopt() {
38}
39
40}
41
42#endif
Definition optional.hpp:23
void reset() noexcept
Definition optional.hpp:31
optional()
Definition optional.hpp:27
lief_errors
LIEF error codes definition.
Definition errors.hpp:23
@ not_found
Definition errors.hpp:25
tl::unexpected< lief_errors > make_error_code(lief_errors e)
Create an standard error code from lief_errors.
Definition errors.hpp:52
LIEF namespace.
Definition Abstract/Binary.hpp:36
tl::unexpected< lief_errors > nullopt()
Definition optional.hpp:36
tl::expected< T, lief_errors > result
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:75