https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68858

            Bug ID: 68858
           Summary: Cannot use fold expression in requirements with two
                    parameters packs
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: public at alisdairm dot net
  Target Milestone: ---

Created attachment 36999
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36999&action=edit
demonstrates requires clause does not recognize parameter packs are constrained
to same length

I am trying to re-implement pair using variadic templates, constrained to a
pack size of exactly two, in order to use fold expressions to simplify
exception specifications and other constraints.  However, I get a hard
(non-SFINAEable) error every time I instantiate my class template, complaining
that parameter packs are not the same length.  Source attached, but in brief,
this is my attempt to contain the packs:

template <typename ...TYPES>
   requires(2 == sizeof...(TYPES))
struct MyPair {
   template <typename ...OTHER_TYPES>
      requires sizeof...(TYPES) == sizeof...(OTHER_TYPES)
          and (true and ... and is_constructible<TYPES, OTHER_TYPES>())
   constexpr
   MyPair(OTHER_TYPES&&... args) 
   noexcept((true and ... and is_nothrow_constructible<TYPES, OTHER_TYPES
&&>()));
};

Error message:
error: mismatched argument pack lengths while expanding
'std::is_constructible<TYPES, OTHER_TYPES>()'
       requires sizeof...(TYPES) == sizeof...(OTHER_TYPES) and (true and ...
and std::is_constructible<TYPES, OTHER_TYPES>())

(note that the example triggering this error does not try to invoke that
constructor, and it parses fine until the implicitly instantiated class
template performs name-lookup for a constructor).


Testing against latest gcc 6 available from MacPorts:  g++ -v

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin15/6.0.0/lto-wrapper
Target: x86_64-apple-darwin15
Configured with:
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_gcc6/gcc6/work/gcc-6-20151129/configure
--prefix=/opt/local --build=x86_64-apple-darwin15
--enable-languages=c,c++,objc,obj-c++,lto,fortran,java
--libdir=/opt/local/lib/gcc6 --includedir=/opt/local/include/gcc6
--infodir=/opt/local/share/info --mandir=/opt/local/share/man
--datarootdir=/opt/local/share/gcc-6 --with-local-prefix=/opt/local
--with-system-zlib --disable-nls --program-suffix=-mp-6
--with-gxx-include-dir=/opt/local/include/gcc6/c++/ --with-gmp=/opt/local
--with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local
--enable-stage1-checking --disable-multilib --enable-lto
--enable-libstdcxx-time --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld
--with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket
--with-pkgversion='MacPorts gcc6 6-20151129_0'
Thread model: posix
gcc version 6.0.0 20151129 (experimental) (MacPorts gcc6 6-20151129_0)

Reply via email to