From 3177c52e9be9c4b762ddeaacd4e037853d0dad59 Mon Sep 17 00:00:00 2001 From: nsubiron Date: Wed, 19 Sep 2018 16:40:39 +0200 Subject: [PATCH] Add Optional class --- LibCarla/source/carla/Optional.h | 36 +++++++++++++++++++ LibCarla/source/compiler/disable-ue4-macros.h | 3 ++ 2 files changed, 39 insertions(+) create mode 100644 LibCarla/source/carla/Optional.h diff --git a/LibCarla/source/carla/Optional.h b/LibCarla/source/carla/Optional.h new file mode 100644 index 000000000..fedc6968b --- /dev/null +++ b/LibCarla/source/carla/Optional.h @@ -0,0 +1,36 @@ +// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma +// de Barcelona (UAB). +// +// This work is licensed under the terms of the MIT license. +// For a copy, see . + +#pragma once + +#include + +namespace carla { + + template + class Optional : private boost::optional { + using parent_type = boost::optional; + public: + + template + explicit Optional(Args &&... args) + : parent_type(std::forward(args)...) {} + + using parent_type::operator*; + using parent_type::operator->; + using parent_type::operator=; + using parent_type::emplace; + using parent_type::reset; + using parent_type::swap; + // using parent_type::value; disabled to avoid exceptions. + using parent_type::value_or; + + bool has_value() const { + return parent_type::is_initialized(); + } + }; + +} // namespace carla diff --git a/LibCarla/source/compiler/disable-ue4-macros.h b/LibCarla/source/compiler/disable-ue4-macros.h index 0e40bc49a..1b4b69d8a 100644 --- a/LibCarla/source/compiler/disable-ue4-macros.h +++ b/LibCarla/source/compiler/disable-ue4-macros.h @@ -20,6 +20,9 @@ # ifndef __cpp_coroutines # define __cpp_coroutines 0 # endif // __cpp_coroutines +# ifndef __cpp_noexcept_function_type +# define __cpp_noexcept_function_type 0 +# endif // __cpp_noexcept_function_type #endif // defined(__clang__) // NOTE(Andrei): disable warning generated by undefined macros