X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fresult.hpp;h=e14f92b253b726b6a14fa3727de4855aaeff9a6b;hb=f7f02a664fc0438f00e6bd09797a3bf4184c123f;hp=b740a0cd0c6be5ae5f44ccf0085d4a52c981fdee;hpb=2fbbf206caf7a2a2940a3c7535a85660b54b6734;p=staging%2Fwindowmanager.git diff --git a/src/result.hpp b/src/result.hpp index b740a0c..e14f92b 100644 --- a/src/result.hpp +++ b/src/result.hpp @@ -1,6 +1,18 @@ -// -// Created by mfritzsc on 7/12/17. -// +/* + * Copyright (C) 2017 Mentor Graphics Development (Deutschland) GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef TMCAGLWM_RESULT_HPP #define TMCAGLWM_RESULT_HPP @@ -30,14 +42,14 @@ struct result { return this->t.value(); } - operator T() { - return this->unwrap(); - } + operator T() { return this->unwrap(); } char const *unwrap_err() { return this->e; } - optional ok() const { return this->t; } - optional err() const { return optional(this->e); } + optional const &ok() const { return this->t; } + optional err() const { + return this->e ? optional(this->e) : nullopt; + } result map_err(std::function f); };