Skip to content

Commit

Permalink
Upgrade clang-format to 11.x, run ./tools/format.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu committed Jan 28, 2021
1 parent eccafd5 commit b22d31b
Show file tree
Hide file tree
Showing 34 changed files with 247 additions and 295 deletions.
5 changes: 2 additions & 3 deletions api/include/opentelemetry/common/key_value_iterable.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ class KeyValueIterable
* the iteration is aborted.
* @return true if every key-value pair was iterated over
*/
virtual bool ForEachKeyValue(
nostd::function_ref<bool(nostd::string_view, common::AttributeValue)> callback) const
noexcept = 0;
virtual bool ForEachKeyValue(nostd::function_ref<bool(nostd::string_view, common::AttributeValue)>
callback) const noexcept = 0;

/**
* @return the number of key-value pairs
Expand Down
5 changes: 2 additions & 3 deletions api/include/opentelemetry/common/key_value_iterable_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ class KeyValueIterableView final : public KeyValueIterable
explicit KeyValueIterableView(const T &container) noexcept : container_{&container} {}

// KeyValueIterable
bool ForEachKeyValue(
nostd::function_ref<bool(nostd::string_view, common::AttributeValue)> callback) const
noexcept override
bool ForEachKeyValue(nostd::function_ref<bool(nostd::string_view, common::AttributeValue)>
callback) const noexcept override
{
auto iter = std::begin(*container_);
auto last = std::end(*container_);
Expand Down
27 changes: 14 additions & 13 deletions api/include/opentelemetry/nostd/detail/invoke.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ template <>
struct Invoke<true /* pmf */, 0 /* is_base_of */>
{
template <typename R, typename T, typename Arg, typename... Args>
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args)
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args)
OPENTELEMETRY_RETURN((std::forward<Arg>(arg).*pmf)(std::forward<Args>(args)...))
};

template <>
struct Invoke<true /* pmf */, 1 /* is_reference_wrapper */>
{
template <typename R, typename T, typename Arg, typename... Args>
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args)
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args)
OPENTELEMETRY_RETURN((std::forward<Arg>(arg).get().*pmf)(std::forward<Args>(args)...))
};

template <>
struct Invoke<true /* pmf */, 2 /* otherwise */>
{
template <typename R, typename T, typename Arg, typename... Args>
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args)
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args)
OPENTELEMETRY_RETURN(((*std::forward<Arg>(arg)).*pmf)(std::forward<Args>(args)...))
};

Expand Down Expand Up @@ -76,27 +76,28 @@ struct Invoke<false /* pmo */, 2 /* otherwise */>
};

template <typename R, typename T, typename Arg, typename... Args>
inline constexpr auto invoke_impl(R T::*f, Arg &&arg, Args &&... args)
OPENTELEMETRY_RETURN(Invoke<std::is_function<R>::value,
(std::is_base_of<T, decay_t<Arg>>::value
? 0
: is_reference_wrapper<decay_t<Arg>>::value ? 1 : 2)>::
invoke(f, std::forward<Arg>(arg), std::forward<Args>(args)...))
inline constexpr auto invoke_impl(R T::*f, Arg &&arg, Args &&...args) OPENTELEMETRY_RETURN(
Invoke<std::is_function<R>::value,
(std::is_base_of<T, decay_t<Arg>>::value ? 0
: is_reference_wrapper<decay_t<Arg>>::value ? 1
: 2)>::invoke(f,
std::forward<Arg>(arg),
std::forward<Args>(args)...))

#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable : 4100)
#endif
template <typename F, typename... Args>
inline constexpr auto invoke_impl(F &&f, Args &&... args)
OPENTELEMETRY_RETURN(std::forward<F>(f)(std::forward<Args>(args)...))
template <typename F, typename... Args>
inline constexpr auto invoke_impl(F &&f, Args &&...args)
OPENTELEMETRY_RETURN(std::forward<F>(f)(std::forward<Args>(args)...))
#ifdef _MSC_VER
# pragma warning(pop)
#endif
} // namespace detail

template <typename F, typename... Args>
inline constexpr auto invoke(F &&f, Args &&... args)
inline constexpr auto invoke(F &&f, Args &&...args)
OPENTELEMETRY_RETURN(detail::invoke_impl(std::forward<F>(f), std::forward<Args>(args)...));

namespace detail
Expand Down
66 changes: 33 additions & 33 deletions api/include/opentelemetry/nostd/detail/recursive_union.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct alt
# pragma warning(disable : 4244)
#endif
template <typename... Args>
inline explicit constexpr alt(in_place_t, Args &&... args) : value(std::forward<Args>(args)...)
inline explicit constexpr alt(in_place_t, Args &&...args) : value(std::forward<Args>(args)...)
{}
#ifdef _MSC_VER
# pragma warning(pop)
Expand All @@ -79,38 +79,38 @@ template <Trait DestructibleTrait, std::size_t Index>
union recursive_union<DestructibleTrait, Index>
{};

#define OPENTELEMETRY_VARIANT_RECURSIVE_UNION(destructible_trait, destructor) \
template <std::size_t Index, typename T, typename... Ts> \
union recursive_union<destructible_trait, Index, T, Ts...> \
{ \
public: \
inline explicit constexpr recursive_union(valueless_t) noexcept : dummy_{} {} \
\
template <typename... Args> \
inline explicit constexpr recursive_union(in_place_index_t<0>, Args &&... args) \
: head_(in_place_t{}, std::forward<Args>(args)...) \
{} \
\
template <std::size_t I, typename... Args> \
inline explicit constexpr recursive_union(in_place_index_t<I>, Args &&... args) \
: tail_(in_place_index_t<I - 1>{}, std::forward<Args>(args)...) \
{} \
\
recursive_union(const recursive_union &) = default; \
recursive_union(recursive_union &&) = default; \
\
destructor \
\
recursive_union & \
operator=(const recursive_union &) = default; \
recursive_union &operator=(recursive_union &&) = default; \
\
private: \
char dummy_; \
alt<Index, T> head_; \
recursive_union<destructible_trait, Index + 1, Ts...> tail_; \
\
friend struct access::recursive_union; \
#define OPENTELEMETRY_VARIANT_RECURSIVE_UNION(destructible_trait, destructor) \
template <std::size_t Index, typename T, typename... Ts> \
union recursive_union<destructible_trait, Index, T, Ts...> \
{ \
public: \
inline explicit constexpr recursive_union(valueless_t) noexcept : dummy_{} {} \
\
template <typename... Args> \
inline explicit constexpr recursive_union(in_place_index_t<0>, Args &&...args) \
: head_(in_place_t{}, std::forward<Args>(args)...) \
{} \
\
template <std::size_t I, typename... Args> \
inline explicit constexpr recursive_union(in_place_index_t<I>, Args &&...args) \
: tail_(in_place_index_t<I - 1>{}, std::forward<Args>(args)...) \
{} \
\
recursive_union(const recursive_union &) = default; \
recursive_union(recursive_union &&) = default; \
\
destructor \
\
recursive_union & \
operator=(const recursive_union &) = default; \
recursive_union &operator=(recursive_union &&) = default; \
\
private: \
char dummy_; \
alt<Index, T> head_; \
recursive_union<destructible_trait, Index + 1, Ts...> tail_; \
\
friend struct access::recursive_union; \
}

OPENTELEMETRY_VARIANT_RECURSIVE_UNION(Trait::TriviallyAvailable, ~recursive_union() = default;);
Expand Down
6 changes: 3 additions & 3 deletions api/include/opentelemetry/nostd/detail/trait.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ template <typename T,
class IsAvailable>
inline constexpr Trait trait()
{
return IsTriviallyAvailable<T>::value
? Trait::TriviallyAvailable
: IsAvailable<T>::value ? Trait::Available : Trait::Unavailable;
return IsTriviallyAvailable<T>::value ? Trait::TriviallyAvailable
: IsAvailable<T>::value ? Trait::Available
: Trait::Unavailable;
}

inline constexpr Trait common_trait_impl(Trait result)
Expand Down
Loading

0 comments on commit b22d31b

Please sign in to comment.