Skip to content

Commit 2781321

Browse files
committed
Simplify code if variadic structured bindings are available
1 parent 9867a24 commit 2781321

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

include/tao/pq/internal/aggregate.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@
1212

1313
namespace tao::pq::internal
1414
{
15+
16+
#if defined( __cpp_structured_bindings ) && ( __cpp_structured_bindings >= 202302L ) && ( __cplusplus >= 202302L )
17+
18+
template< typename T >
19+
requires( std::is_aggregate_v< T > && !std::is_empty_v< T > && !std::is_union_v< T > )
20+
constexpr auto tie_aggregate( const T& value ) noexcept
21+
{
22+
const auto& [... values ] = value;
23+
return std::tie( values... );
24+
}
25+
26+
#else
27+
1528
struct convert_to_any
1629
{
1730
template< typename T >
@@ -97,6 +110,8 @@ namespace tao::pq::internal
97110
#undef TAO_PQ_10
98111
#undef TAO_PQ_TIE10
99112

113+
#endif
114+
100115
} // namespace tao::pq::internal
101116

102117
#endif

0 commit comments

Comments
 (0)