Install SeisComP and scanloc ARM64 nightly packages
This commit is contained in:
@ -21,41 +21,66 @@
|
||||
#ifndef SEISCOMP_CORE_OPTIONAL_H
|
||||
#define SEISCOMP_CORE_OPTIONAL_H
|
||||
|
||||
|
||||
#include <seiscomp/core.h>
|
||||
|
||||
#include <exception>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/none.hpp>
|
||||
#include <exception>
|
||||
#include <optional>
|
||||
#include <type_traits>
|
||||
|
||||
|
||||
namespace Seiscomp {
|
||||
namespace Core {
|
||||
|
||||
/** \brief Redefines boost::optional<T>
|
||||
/** \brief Redefines std::optional<T>
|
||||
* Optional values can be set or unset.
|
||||
* \code
|
||||
* void print(const Optional<int>::Impl& v) {
|
||||
* void print(const Optional<int> &v) {
|
||||
* if ( !v )
|
||||
* cout << "value of v is not set" << endl;
|
||||
* else
|
||||
* cout << *v << endl;
|
||||
* }
|
||||
*
|
||||
* Optional<int>::Impl a = 5;
|
||||
* Optional<int> a = 5;
|
||||
* print(a); // output: "5"
|
||||
* a = None;
|
||||
* print(a); // output: "value of v is not set"
|
||||
* \endcode
|
||||
*/
|
||||
template <typename T>
|
||||
struct Optional {
|
||||
typedef ::boost::optional<T> Impl;
|
||||
};
|
||||
using Optional = ::std::optional<T>;
|
||||
|
||||
using NoneType = ::std::nullopt_t;
|
||||
|
||||
/** Defines None */
|
||||
SC_SYSTEM_CORE_API extern ::boost::none_t const None;
|
||||
SC_SYSTEM_CORE_API extern NoneType const None;
|
||||
|
||||
|
||||
template <class...>
|
||||
struct False : std::integral_constant<bool, false> {};
|
||||
|
||||
template <class...>
|
||||
struct True : std::integral_constant<bool, true> {};
|
||||
|
||||
|
||||
// Checks whether a type is wrapped with optional or not.
|
||||
template <typename>
|
||||
struct isOptional : std::false_type {};
|
||||
|
||||
template<template<class...> class U, typename ...Args>
|
||||
struct isOptional<U<Args...>>
|
||||
: std::integral_constant<
|
||||
bool,
|
||||
std::is_base_of<std::optional<Args...>, U<Args...>>::value
|
||||
|| std::is_base_of<boost::optional<Args...>, U<Args...>>::value
|
||||
> {};
|
||||
|
||||
|
||||
|
||||
template <typename T>
|
||||
T value(const boost::optional<T>&);
|
||||
T value(const Optional<T>&);
|
||||
|
||||
class SC_SYSTEM_CORE_API ValueError : public std::exception {
|
||||
public:
|
||||
@ -63,16 +88,19 @@ class SC_SYSTEM_CORE_API ValueError : public std::exception {
|
||||
~ValueError() throw();
|
||||
|
||||
public:
|
||||
const char* what() const throw();
|
||||
const char* what() const throw() override;
|
||||
};
|
||||
|
||||
/** Macro to use optional values easily */
|
||||
#define OPT(T) Seiscomp::Core::Optional<T>::Impl
|
||||
#define OPT(T) Seiscomp::Core::Optional<T>
|
||||
/** Macro to use optional values as const reference */
|
||||
#define OPT_CR(T) const Seiscomp::Core::Optional<T>::Impl&
|
||||
#define OPT_CR(T) const Seiscomp::Core::Optional<T>&
|
||||
|
||||
|
||||
#include <seiscomp/core/optional.inl>
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user