Skip to content

Commit

Permalink
Remove Clang warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lackhole committed Aug 29, 2024
1 parent c586cf4 commit 1a2b5dc
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 19 deletions.
2 changes: 1 addition & 1 deletion include/preview/__concepts/derived_from_single_crtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ template<typename T, typename = void>

struct has_typename_preview_derived : std::false_type {};
template<typename T>
struct has_typename_preview_derived<T, void_t<typename T::_$preview_derived>> : std::true_type {};
struct has_typename_preview_derived<T, void_t<typename T::_preview_derived>> : std::true_type {};

template<template<typename> class Base>
struct derived_from_single_crtp_tester {
Expand Down
2 changes: 1 addition & 1 deletion include/preview/__iterator/iterator_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct iterator_traits_legacy_input_iterator {
using value_type = typename indirectly_readable_traits<Iter>::value_type;
using pointer = typename iterator_traits_typename_pointer<Iter>::type;
using reference = typename iterator_traits_typename_reference<Iter>::type;
using iterator_category = typename iterator_traits_typename_iterator_category<Iter>::type;;
using iterator_category = typename iterator_traits_typename_iterator_category<Iter>::type;
};

template<
Expand Down
10 changes: 5 additions & 5 deletions include/preview/__optional/optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class optional : private detail::optional_control_smf<T> {

// constructors
constexpr optional() noexcept = default;
constexpr optional(nullopt_t) noexcept {};
constexpr optional(nullopt_t) noexcept {}
constexpr optional(const optional& other) = default;
constexpr optional(optional&& other) = default;

Expand Down Expand Up @@ -714,7 +714,7 @@ constexpr inline bool operator!=(nullopt_t, const optional<T>& opt) noexcept {
}

template<typename T>
constexpr inline bool operator<(const optional<T>& opt, nullopt_t) noexcept {
constexpr inline bool operator<(const optional<T>&, nullopt_t) noexcept {
return false;
}

Expand All @@ -729,7 +729,7 @@ constexpr inline bool operator<=(const optional<T>& opt, nullopt_t) noexcept {
}

template<typename T>
constexpr inline bool operator<=(nullopt_t, const optional<T>& opt) noexcept {
constexpr inline bool operator<=(nullopt_t, const optional<T>&) noexcept {
return true;
}

Expand All @@ -739,12 +739,12 @@ constexpr inline bool operator>(const optional<T>& opt, nullopt_t) noexcept {
}

template<typename T>
constexpr inline bool operator>(nullopt_t, const optional<T>& opt) noexcept {
constexpr inline bool operator>(nullopt_t, const optional<T>&) noexcept {
return false;
}

template<typename T>
constexpr inline bool operator>=(const optional<T>& opt, nullopt_t) noexcept {
constexpr inline bool operator>=(const optional<T>&, nullopt_t) noexcept {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion include/preview/__ranges/range_adaptor_closure.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct range_adaptor_closure {
static_assert(std::is_object<Derived>::value, "Constraints not satisfied");
static_assert(same_as<Derived, std::remove_cv_t<Derived>>::value, "Constraints not satisfied");

using _$preview_derived = Derived;
using _preview_derived = Derived;

template<typename Range, typename This, std::enable_if_t<conjunction<
same_as<Derived, remove_cvref_t<This>>,
Expand Down
2 changes: 1 addition & 1 deletion include/preview/__ranges/view_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class view_interface {
static_assert(std::is_class<Derived>::value, "Constraints not satisfied");
static_assert(std::is_same<Derived, std::remove_cv_t<Derived>>::value, "Constraints not satisfied");

using _$preview_derived = Derived;
using _preview_derived = Derived;

template<typename D = Derived, derived_is<D, disjunction<
sized_range<D>,
Expand Down
10 changes: 5 additions & 5 deletions include/preview/__ranges/views/join_with_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,11 @@ class join_with_view : public detail::join_with_view_base<V, Pattern, join_with_
return !(x == y);
}

friend constexpr decltype(auto) iter_move(const iterator& i) {
using R = common_reference_t<range_rvalue_reference_t<InnerBase>, range_rvalue_reference_t<PatternBase>>;
return i.inner_it_.visit([](auto&& i) -> R {
return ranges::iter_move(std::forward<decltype(i)>(i));
});
friend constexpr decltype(auto) iter_move(const iterator& x) {
using rvalue_reference = common_reference_t<
iter_rvalue_reference_t<InnerIter>,
iter_rvalue_reference_t<PatternIter>>;
return preview::visit<rvalue_reference>(ranges::iter_move, x.inner_it_);
}

template<typename IS = indirectly_swappable<iterator_t<InnerBase>, iterator_t<PatternBase>>, std::enable_if_t<IS::value, int> = 0>
Expand Down
9 changes: 9 additions & 0 deletions include/preview/__ranges/views/split_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
#include "preview/__type_traits/remove_cvref.h"
#include "preview/__utility/cxx20_rel_ops.h"

#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wshadow"
#endif

namespace preview {
namespace ranges {

Expand Down Expand Up @@ -270,4 +275,8 @@ split_view(R&&, range_value_t<R>)
} // namespace ranges
} // namespace preview

#ifdef __clang__
#pragma clang diagnostic pop
#endif

#endif // PREVIEW_RANGES_VIEWS_SPLIT_VIEW_H_
4 changes: 2 additions & 2 deletions include/preview/__type_traits/detail/size.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ constexpr inline auto size(const C& c) -> decltype(c.size())
}

template<typename T, std::size_t N>
constexpr inline std::size_t size(const T (&array)[N]) noexcept
constexpr inline std::size_t size(const T (&)[N]) noexcept
{
return N;
}
Expand All @@ -33,7 +33,7 @@ constexpr inline auto ssize(const C& c)
}

template<typename T, std::size_t N>
constexpr inline std::ptrdiff_t ssize(const T (&array)[N]) noexcept
constexpr inline std::ptrdiff_t ssize(const T (&)[N]) noexcept
{
return static_cast<std::ptrdiff_t>(N);
}
Expand Down
9 changes: 9 additions & 0 deletions include/preview/__utility/cxx20_rel_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
#include "preview/__type_traits/negation.h"
#include "preview/__type_traits/void_t.h"

#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif

// automatically generates comparison operators based on user-defined `operator==` and `operator<` in C++20 way

namespace preview {
Expand Down Expand Up @@ -191,4 +196,8 @@ struct is_greater_equal_than_comparable : detail::is_greater_equal_than_comparab
} // namespace rel_ops
} // namespace preview

#ifdef __clang__
#pragma clang diagnostic pop
#endif

#endif // PREVIEW_UTILITY_CXX20_REL_OPS_H_
2 changes: 1 addition & 1 deletion include/preview/__variant/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct variant_hash_visitor {
}

template<typename T>
constexpr std::size_t operator()(const T& x, in_place_index_t<variant_npos>) const {
constexpr std::size_t operator()(const T&, in_place_index_t<variant_npos>) const {
return 0;
}
};
Expand Down
4 changes: 2 additions & 2 deletions include/preview/__variant/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ constexpr decltype(auto) variant_raw_visit_impl2(Union&& u, F&& func, in_place_i
template<std::size_t Base, typename Union, typename F, typename... Args>
constexpr decltype(auto) variant_raw_visit_recurse(std::size_t i, Union&& u, F&& func, in_place_index_t<Base>, std::true_type, Args&&... args);
template<std::size_t Base, typename Union, typename F, typename... Args>
constexpr decltype(auto) variant_raw_visit_recurse(std::size_t i, Union&& u, F&& func, in_place_index_t<Base>, std::false_type, Args&&... args) {
constexpr decltype(auto) variant_raw_visit_recurse(std::size_t, Union&& u, F&& func, in_place_index_t<Base>, std::false_type, Args&&... args) {
// unreachable
return variant_raw_visit_impl2(std::forward<Union>(u), std::forward<F>(func), in_place_index<0>, std::forward<Args>(args)...);
}
Expand Down Expand Up @@ -426,7 +426,7 @@ struct variant_base {
}

void swap_base_impl(variant_base& rhs, std::false_type /* trivial */) {
variant_raw_visit(index_, union_, [this, &rhs](auto& x, auto i) {
variant_raw_visit(index_, union_, [this, &rhs](auto&, auto i) {
constexpr std::size_t I = index_value<decltype(i)>::value;
variant_raw_visit(rhs.index_, rhs.storage(), swapper_inner<I>{*this, rhs});
});
Expand Down
9 changes: 9 additions & 0 deletions include/preview/__variant/variant_npos.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@

#include "preview/__core/inline_variable.h"

#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wsign-conversion"
#endif

namespace preview {

PREVIEW_INLINE_VARIABLE constexpr std::size_t variant_npos = -1;

} // namespace preview

#ifdef __clang__
#pragma clang diagnostic pop
#endif

#endif // PREVIEW_VARIANT_VARIANT_NPOS_H_

0 comments on commit 1a2b5dc

Please sign in to comment.