Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Support C++23 tuple APIs #61

Closed
ldalessa opened this issue Apr 30, 2023 · 1 comment
Closed

[FEATURE] Support C++23 tuple APIs #61

ldalessa opened this issue Apr 30, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@ldalessa
Copy link

ldalessa commented Apr 30, 2023

A bunch of the std library language around tuple has changed, I think specifically to support std::tuple proxy value/reference types for std::views::zip. Many of these changes are in p2321.

I ran into this in this example of using a kumi::tie as a reference tuple type for an SoA iterator, and trying to use std::ranges::sort on the range. https://godbolt.org/z/9bYb1oM8z.

Currently the first compiler error I run into is the following common_reference failure, which I guess requires specializing basic_common_reference, however there could be more problems hidden behind this one.

/opt/compiler-explorer/clang-16.0.0/bin/../include/c++/v1/__type_traits/common_reference.h:113:1: note: because substituted constraint expression is ill-formed: no type named 'type' in 'std::common_reference<kumi::tuple<unsigned int &, unsigned char &, unsigned int &> &&, kumi::tuple<unsigned int, unsigned char, unsigned int> &>'
using common_reference_t = typename common_reference<_Types...>::type;
^
1 error generated.

edit: punctuation

@ldalessa ldalessa added the enhancement New feature or request label Apr 30, 2023
@jfalcou
Copy link
Owner

jfalcou commented May 12, 2023

This is the code to add :

namespace std
{
  template< kumi::product_type TTuple,kumi::product_type UTuple
          , template<class> class TQual, template<class> class UQual 
          , typename Indexer = std::make_index_sequence<kumi::size_v<TTuple>>
          >
  struct make_basic_common_ref;
  
  template< kumi::product_type TTuple,kumi::product_type UTuple
          , template<class> class TQual, template<class> class UQual 
          , std::size_t... I
          >
  struct make_basic_common_ref<TTuple,UTuple,TQual,UQual
                              , std::index_sequence<I...>
                              >
  {
    using type = kumi::tuple<std::common_reference_t< TQual<std::tuple_element_t<I,TTuple>>
                                                    , UQual<std::tuple_element_t<I,UTuple>>
                                                    >...
                            >;
  };


  template< kumi::product_type TTuple,kumi::product_type UTuple
          , template<class> class TQual, template<class> class UQual >
  requires( kumi::size_v<TTuple> == kumi::size_v<UTuple>)
  struct basic_common_reference<TTuple, UTuple, TQual, UQual>
  : make_basic_common_ref<TTuple,UTuple,TQual,UQual>
  {};
}

but looks like kumi::tuple constructor is not enough. Alas, I can't add it or I won't be aggregate anymore.
Will see how to do that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants