Skip to content

Commit 07eadfb

Browse files
committed
Merging 'develop' into 'master' for 1.7.0
2 parents bf42400 + 4f5157b commit 07eadfb

File tree

10 files changed

+136
-50
lines changed

10 files changed

+136
-50
lines changed

RELEASE_NOTES.md

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
Release notes for Hana 1.6.1
1+
Release notes for Hana 1.7.0
22
============================
3-
4-
- Official support for Xcode 6, 7 and 8, 9, 10 and LLVM Clang 3.5, 3.6, 3.7,
5-
and 3.8 has has been dropped. The library should still work with these
6-
compilers, however they are not being tested regularly anymore, so they are
7-
not officially supported.
8-
- The `hana::traits::result_of` trait has been removed. Since `std::result_of`
9-
has been removed from the Standard in C++20, users should move away from it.
3+
- Disable the definition of traits::is_pod in C++20 and later, due to its
4+
deprecation.

doc/tutorial.hpp

+35-35
Original file line numberDiff line numberDiff line change
@@ -3576,41 +3576,41 @@ in pseudo-code, the actual implementation sometimes being slightly hard to
35763576
understand. This section defines terms used in the reference and in the
35773577
pseudo-code used to describe some functions.
35783578
3579-
@anchor tutorial-glossary-forwarded
3580-
#### `forwarded(x)`
3581-
Means that the object is forwarded optimally. This means that if `x` is a
3582-
parameter, it is `std::forward`ed, and if it is a captured variable, it is
3583-
moved from whenever the enclosing lambda is an rvalue.
3584-
3585-
Also note that when `x` can be moved from, the statement `return forwarded(x);`
3586-
in a function with `decltype(auto)` does not mean that an rvalue reference to
3587-
`x` will be returned, which would create a dangling reference. Rather, it
3588-
means that `x` is returned by value, the value being constructed with the
3589-
`std::forward`ed `x`.
3590-
3591-
@anchor tutorial-glossary-perfect_capture
3592-
#### `perfect-capture`
3593-
This is used in lambdas to signify that the captured variables are
3594-
initialized using perfect forwarding, as if `[x(forwarded(x))...]() { }`
3595-
had been used.
3596-
3597-
@anchor tutorial-glossary-tag_dispatched
3598-
#### `tag-dispatched`
3599-
This means that the documented function uses [tag dispatching]
3600-
(@ref tutorial-core-tag_dispatching), and hence the exact
3601-
implementation depends on the model of the concept associated
3602-
to the function.
3603-
3604-
@anchor tutorial-glossary-implementation_defined
3605-
#### `implementation-defined`
3606-
This expresses the fact that the exact implementation of an entity (usually a
3607-
type) should not be relied upon by users. In particular, this means that one
3608-
can not assume anything beyond what is written explicitly in the documentation.
3609-
Usually, the concepts satisfied by an implementation-defined entity will be
3610-
documented, because one could otherwise do nothing with it. Concretely,
3611-
assuming too much about an implementation-defined entity will probably
3612-
not kill you, but it will very probably break your code when you update
3613-
to a newer version of Hana.
3579+
- @anchor tutorial-glossary-forwarded `forwarded(x)`
3580+
3581+
Means that the object is forwarded optimally. This means that if `x` is a
3582+
parameter, it is `std::forward`ed, and if it is a captured variable, it is
3583+
moved from whenever the enclosing lambda is an rvalue.
3584+
3585+
Also note that when `x` can be moved from, the statement `return forwarded(x);`
3586+
in a function with `decltype(auto)` does not mean that an rvalue reference to
3587+
`x` will be returned, which would create a dangling reference. Rather, it
3588+
means that `x` is returned by value, the value being constructed with the
3589+
`std::forward`ed `x`.
3590+
3591+
- @anchor tutorial-glossary-perfect_capture `perfect-capture`
3592+
3593+
This is used in lambdas to signify that the captured variables are
3594+
initialized using perfect forwarding, as if `[x(forwarded(x))...]() { }`
3595+
had been used.
3596+
3597+
- @anchor tutorial-glossary-tag_dispatched `tag-dispatched`
3598+
3599+
This means that the documented function uses [tag dispatching]
3600+
(@ref tutorial-core-tag_dispatching), and hence the exact
3601+
implementation depends on the model of the concept associated
3602+
to the function.
3603+
3604+
- @anchor tutorial-glossary-implementation_defined `implementation-defined`
3605+
3606+
This expresses the fact that the exact implementation of an entity (usually a
3607+
type) should not be relied upon by users. In particular, this means that one
3608+
can not assume anything beyond what is written explicitly in the documentation.
3609+
Usually, the concepts satisfied by an implementation-defined entity will be
3610+
documented, because one could otherwise do nothing with it. Concretely,
3611+
assuming too much about an implementation-defined entity will probably
3612+
not kill you, but it will very probably break your code when you update
3613+
to a newer version of Hana.
36143614
36153615
36163616

include/boost/hana/core/tag_of.hpp

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Distributed under the Boost Software License, Version 1.0.
1515
#include <boost/hana/config.hpp>
1616
#include <boost/hana/core/when.hpp>
1717

18+
#include <type_traits>
19+
1820

1921
BOOST_HANA_NAMESPACE_BEGIN
2022
//! @cond
@@ -44,6 +46,14 @@ BOOST_HANA_NAMESPACE_BEGIN
4446
template <typename T> struct tag_of<T const volatile> : tag_of<T> { };
4547
template <typename T> struct tag_of<T&> : tag_of<T> { };
4648
template <typename T> struct tag_of<T&&> : tag_of<T> { };
49+
50+
namespace detail {
51+
template <typename T>
52+
struct has_idempotent_tag
53+
: std::is_same<hana::tag_of_t<T>,
54+
std::remove_const_t<std::remove_reference_t<T>>>
55+
{ };
56+
}
4757
BOOST_HANA_NAMESPACE_END
4858

4959
#endif // !BOOST_HANA_CORE_TAG_OF_HPP

include/boost/hana/detail/operators/comparable.hpp

+12-4
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,23 @@ BOOST_HANA_NAMESPACE_BEGIN namespace detail {
2626

2727
namespace operators {
2828
template <typename X, typename Y, typename = typename std::enable_if<
29-
detail::comparable_operators<typename hana::tag_of<X>::type>::value ||
30-
detail::comparable_operators<typename hana::tag_of<Y>::type>::value
29+
!detail::has_idempotent_tag<X>::value &&
30+
!detail::has_idempotent_tag<Y>::value &&
31+
(detail::comparable_operators<
32+
typename hana::tag_of<X>::type>::value ||
33+
detail::comparable_operators<
34+
typename hana::tag_of<Y>::type>::value)
3135
>::type>
3236
constexpr auto operator==(X&& x, Y&& y)
3337
{ return hana::equal(static_cast<X&&>(x), static_cast<Y&&>(y)); }
3438

3539
template <typename X, typename Y, typename = typename std::enable_if<
36-
detail::comparable_operators<typename hana::tag_of<X>::type>::value ||
37-
detail::comparable_operators<typename hana::tag_of<Y>::type>::value
40+
!detail::has_idempotent_tag<X>::value &&
41+
!detail::has_idempotent_tag<Y>::value &&
42+
(detail::comparable_operators<
43+
typename hana::tag_of<X>::type>::value ||
44+
detail::comparable_operators<
45+
typename hana::tag_of<Y>::type>::value)
3846
>::type>
3947
constexpr auto operator!=(X&& x, Y&& y)
4048
{ return hana::not_equal(static_cast<X&&>(x), static_cast<Y&&>(y)); }

include/boost/hana/equal.hpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,10 @@ BOOST_HANA_NAMESPACE_BEGIN
191191
}
192192

193193
template <typename S>
194-
struct equal_impl<S, S, when<hana::Struct<S>::value>> {
194+
struct equal_impl<S, S, when<
195+
hana::Struct<S>::value &&
196+
!detail::EqualityComparable<S, S>::value
197+
>> {
195198
template <typename X, typename Y>
196199
static constexpr auto apply(X const& x, Y const& y) {
197200
return hana::all_of(hana::accessors<S>(),

include/boost/hana/traits.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ BOOST_HANA_NAMESPACE_BEGIN namespace traits {
6767
constexpr auto is_trivial = detail::hana_trait<std::is_trivial>{};
6868
constexpr auto is_trivially_copyable = detail::hana_trait<std::is_trivially_copyable>{};
6969
constexpr auto is_standard_layout = detail::hana_trait<std::is_standard_layout>{};
70+
#if __cplusplus < 202002L
7071
constexpr auto is_pod = detail::hana_trait<std::is_pod>{};
72+
#endif
7173
constexpr auto is_literal_type = detail::hana_trait<std::is_literal_type>{};
7274
constexpr auto is_empty = detail::hana_trait<std::is_empty>{};
7375
constexpr auto is_polymorphic = detail::hana_trait<std::is_polymorphic>{};

include/boost/hana/version.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ Distributed under the Boost Software License, Version 1.0.
2424

2525
//! @ingroup group-config
2626
//! Macro expanding to the minor version of the library, i.e. the `y` in `x.y.z`.
27-
#define BOOST_HANA_MINOR_VERSION 6
27+
#define BOOST_HANA_MINOR_VERSION 7
2828

2929
//! @ingroup group-config
3030
//! Macro expanding to the patch level of the library, i.e. the `z` in `x.y.z`.
31-
#define BOOST_HANA_PATCH_VERSION 1
31+
#define BOOST_HANA_PATCH_VERSION 0
3232

3333
//! @ingroup group-config
3434
//! Macro expanding to the full version of the library, in hexadecimal

test/issues/github_460.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright Jason Rice 2020
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4+
5+
#include <boost/hana/define_struct.hpp>
6+
#include <boost/hana/equal.hpp>
7+
#include <boost/hana/members.hpp>
8+
#include <boost/hana/not_equal.hpp>
9+
namespace hana = boost::hana;
10+
11+
12+
struct SomeStruct {
13+
BOOST_HANA_DEFINE_STRUCT(SomeStruct, (int, x));
14+
15+
constexpr bool operator==(SomeStruct const& other) {
16+
return hana::equal(hana::members(*this), hana::members(other));
17+
}
18+
19+
constexpr bool operator!=(SomeStruct const& other) {
20+
return hana::not_equal(hana::members(*this), hana::members(other));
21+
}
22+
};
23+
24+
int main() {
25+
static_assert(SomeStruct{5} == SomeStruct{5}, "");
26+
static_assert(hana::equal(SomeStruct{5}, SomeStruct{5}), "");
27+
}

test/issues/github_470.cpp

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright Jason Rice 2020
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4+
5+
#include <boost/hana/equal.hpp>
6+
#include <boost/hana/not_equal.hpp>
7+
#include <boost/hana/tuple.hpp>
8+
#include <cassert>
9+
namespace hana = boost::hana;
10+
11+
namespace {
12+
template <typename T>
13+
struct optional {
14+
T t;
15+
};
16+
17+
template <typename T>
18+
constexpr bool operator==(optional<T> const& o, T const& t) {
19+
return o.t == t;
20+
}
21+
template <typename T>
22+
constexpr bool operator==(T const& t, optional<T> const& o) {
23+
return o.t == t;
24+
}
25+
template <typename T>
26+
constexpr bool operator!=(optional<T> const& o, T const& t) {
27+
return o.t != t;
28+
}
29+
template <typename T>
30+
constexpr bool operator!=(T const& t, optional<T> const& o) {
31+
return o.t != t;
32+
}
33+
}
34+
35+
int main() {
36+
boost::hana::tuple<int> x{};
37+
optional<boost::hana::tuple<int>> attr{x};
38+
assert(attr == x); // <-- Kablooey!
39+
}

test/type/traits.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ int main() {
5353
hana::traits::is_trivial(s);
5454
hana::traits::is_trivially_copyable(s);
5555
hana::traits::is_standard_layout(s);
56+
#if __cplusplus < 202002L
5657
hana::traits::is_pod(s);
58+
#endif
5759
hana::traits::is_literal_type(s);
5860
hana::traits::is_empty(s);
5961
hana::traits::is_polymorphic(s);

0 commit comments

Comments
 (0)