Clang format

This commit is contained in:
Simon Brand
2017-11-03 14:29:02 +00:00
parent 59cf950873
commit f6802daada

View File

@ -171,8 +171,8 @@ template <class T, class... U>
using disable_if_ret_void = enable_if_t<!returns_void<T &&, U...>::value>;
template <class T, class U>
using enable_forward_value =
detail::enable_if_t<std::is_constructible<T, U &&>::value &&
using enable_forward_value = detail::enable_if_t<
std::is_constructible<T, U &&>::value &&
!std::is_same<detail::decay_t<U>, in_place_t>::value &&
!std::is_same<optional<T>, detail::decay_t<U>>::value>;
@ -216,7 +216,8 @@ using enable_assign_from_other = detail::enable_if_t<
// TODO make a version which works with MSVC
template <class T, class U = T> struct is_swappable : std::true_type {};
template <class T, class U = T> struct is_nothrow_swappable : std::true_type {};
template <class T, class U = T>
struct is_nothrow_swappable : std::true_type {};
#else
// https://stackoverflow.com/questions/26744589/what-is-a-proper-way-to-implement-is-swappable-to-test-for-the-swappable-concept
namespace swap_adl_tests {
@ -285,8 +286,9 @@ struct is_nothrow_swappable
};
#endif
// The storage base manages the actual storage, and correctly propagates trivial
// destruction from T This case is for when T is trivially destructible
// The storage base manages the actual storage, and correctly propagates
// trivial destruction from T This case is for when T is trivially
// destructible
template <class T, bool = ::std::is_trivially_destructible<T>::value>
struct optional_storage_base {
TL_OPTIONAL_11_CONSTEXPR optional_storage_base() noexcept
@ -334,7 +336,8 @@ template <class T> struct optional_storage_base<T, true> {
// This base class provides some handy member functions which can be used in
// further derived classes
template <class T> struct optional_operations_base : optional_storage_base<T> {
template <class T>
struct optional_operations_base : optional_storage_base<T> {
using optional_storage_base<T>::optional_storage_base;
void hard_reset() noexcept {
@ -411,7 +414,8 @@ struct optional_move_base : optional_copy_base<T> {
#else
template <class T, bool = false> struct optional_move_base;
#endif
template <class T> struct optional_move_base<T, false> : optional_copy_base<T> {
template <class T>
struct optional_move_base<T, false> : optional_copy_base<T> {
using optional_copy_base<T>::optional_copy_base;
optional_move_base() = default;
@ -608,12 +612,12 @@ public:
const char *what() const noexcept { return "Optional has no value"; }
};
/// An optional object is an object that contains the storage for another object
/// and manages the lifetime of this contained object, if any. The contained
/// object may be initialized after the optional object has been initialized,
/// and may be destroyed before the optional object has been destroyed. The
/// initialization state of the contained object is tracked by the optional
/// object.
/// An optional object is an object that contains the storage for another
/// object and manages the lifetime of this contained object, if any. The
/// contained object may be initialized after the optional object has been
/// initialized, and may be destroyed before the optional object has been
/// destroyed. The initialization state of the contained object is tracked by
/// the optional object.
template <class T>
class optional : private detail::optional_move_assign_base<T>,
private detail::optional_delete_ctor_base<T>,
@ -628,11 +632,10 @@ public:
#if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && \
!defined(TL_EXPECTED_GCC54)
/// \group and_then
/// Carries out some operation which returns an optional on the stored object
/// if there is one.
/// \requires `std::invoke(std::forward<F>(f), value())`
/// returns a `std::optional<U>` for some `U`. \returns Let `U` be the result
/// of `std::invoke(std::forward<F>(f), value())`. Returns a
/// Carries out some operation which returns an optional on the stored
/// object if there is one. \requires `std::invoke(std::forward<F>(f),
/// value())` returns a `std::optional<U>` for some `U`. \returns Let `U` be
/// the result of `std::invoke(std::forward<F>(f), value())`. Returns a
/// `std::optional<U>`. The return value is empty if `*this` is empty,
/// otherwise the return value of `std::invoke(std::forward<F>(f), value())`
/// is returned.
@ -928,8 +931,8 @@ public:
}
#endif
/// \brief Maps the stored value with `f` if there is one, otherwise calls `u`
/// and returns the result.
/// \brief Maps the stored value with `f` if there is one, otherwise calls
/// `u` and returns the result.
///
/// \details If there is a value stored, then `f` is
/// called with `**this` and the value is returned. Otherwise
@ -944,7 +947,8 @@ public:
}
/// \group map_or_else
/// \synopsis template <class F, class U>\nauto map_or_else(F &&f, U &&u) &&;
/// \synopsis template <class F, class U>\nauto map_or_else(F &&f, U &&u)
/// &&;
template <class F, class U>
detail::invoke_result_t<U> map_or_else(F &&f, U &&u) && {
return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this))
@ -1065,23 +1069,24 @@ public:
/// Copy constructor
///
/// If `rhs` contains a value, the stored value is direct-initialized with it.
/// Otherwise, the constructed optional is empty.
/// If `rhs` contains a value, the stored value is direct-initialized with
/// it. Otherwise, the constructed optional is empty.
TL_OPTIONAL_11_CONSTEXPR optional(const optional &rhs) = default;
/// Move constructor
///
/// If `rhs` contains a value, the stored value is direct-initialized with it.
/// Otherwise, the constructed optional is empty.
/// If `rhs` contains a value, the stored value is direct-initialized with
/// it. Otherwise, the constructed optional is empty.
TL_OPTIONAL_11_CONSTEXPR optional(optional &&rhs) = default;
/// Constructs the stored value in-place using the given arguments.
/// \group in_place
/// \synopsis template <class... Args> constexpr explicit optional(in_place_t,
/// Args&&... args);
/// \synopsis template <class... Args> constexpr explicit
/// optional(in_place_t, Args&&... args);
template <class... Args>
constexpr explicit optional(
detail::enable_if_t<std::is_constructible<T, Args...>::value, in_place_t>,
detail::enable_if_t<std::is_constructible<T, Args...>::value,
in_place_t>,
Args &&... args)
: base(in_place, std::forward<Args>(args)...) {}
@ -1114,9 +1119,9 @@ public:
/// Converting copy constructor.
/// \synopsis template <class U> optional(const optional<U> &rhs);
template <
class U, detail::enable_from_other<T, U, const U &> * = nullptr,
detail::enable_if_t<std::is_convertible<const U &, T>::value> * = nullptr>
template <class U, detail::enable_from_other<T, U, const U &> * = nullptr,
detail::enable_if_t<std::is_convertible<const U &, T>::value> * =
nullptr>
optional(const optional<U> &rhs) {
this->construct(*rhs);
}
@ -1233,8 +1238,8 @@ public:
return *this;
}
/// Constructs the value in-place, destroying the current one if there is one.
/// \group emplace
/// Constructs the value in-place, destroying the current one if there is
/// one. \group emplace
template <class... Args> T &emplace(Args &&... args) {
static_assert(std::is_constructible<T, Args &&...>::value,
"T must be constructible with Args");
@ -1309,7 +1314,9 @@ public:
#ifndef TL_OPTIONAL_NO_CONSTRR
/// \exclude
constexpr const T &&operator*() const && { return std::move(this->m_value); }
constexpr const T &&operator*() const && {
return std::move(this->m_value);
}
#endif
/// \returns whether or not the optional has a value
@ -1383,8 +1390,8 @@ public:
/// \brief Compares two optional objects
/// \details If both optionals contain a value, they are compared with `T`s
/// relational operators. Otherwise `lhs` and `rhs` are equal only if they are
/// both empty, and `lhs` is less than `rhs` only if `rhs` is empty and `lhs` is
/// not.
/// both empty, and `lhs` is less than `rhs` only if `rhs` is empty and `lhs`
/// is not.
template <class T, class U>
inline constexpr bool operator==(const optional<T> &lhs,
const optional<U> &rhs) {
@ -1489,8 +1496,8 @@ inline constexpr bool operator>=(nullopt_t, const optional<T> &rhs) noexcept {
/// \group relop_t
/// \brief Compares the optional with a value.
/// \details If the optional has a value, it is compared with the other value
/// using `T`s relational operators. Otherwise, the optional is considered less
/// than the value.
/// using `T`s relational operators. Otherwise, the optional is considered
/// less than the value.
template <class T, class U>
inline constexpr bool operator==(const optional<T> &lhs, const U &rhs) {
return lhs.has_value() ? *lhs == rhs : false;
@ -1551,9 +1558,11 @@ inline constexpr bool operator>=(const U &lhs, const optional<T> &rhs) {
return rhs.has_value() ? lhs >= *rhs : true;
}
/// \synopsis template <class T>\nvoid swap(optional<T> &lhs, optional<T> &rhs);
/// \synopsis template <class T>\nvoid swap(optional<T> &lhs, optional<T>
/// &rhs);
template <class T,
detail::enable_if_t<std::is_move_constructible<T>::value> * = nullptr,
detail::enable_if_t<std::is_move_constructible<T>::value> * =
nullptr,
detail::enable_if_t<detail::is_swappable<T>::value> * = nullptr>
void swap(optional<T> & lhs,
optional<T> & rhs) noexcept(noexcept(lhs.swap(rhs))) {