This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/67901] New: [concepts] overloading bug when considered more specialized vs more constrained


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

            Bug ID: 67901
           Summary: [concepts] overloading bug when considered more
                    specialized vs more constrained
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ryan.burn at gmail dot com
  Target Milestone: ---

I think the below code should compile. 

>From section 14.6.6.2:

Partial ordering selects which of two function templates is more specialized
than the other by transforming each template in turn (see next paragraph) and
performing template argument de- duction using the function type. The deduction
process determines whether one of the templates is more specialized than the
other. If so, the more specialized template is the one chosen by the partial
ordering process. If both deductions succeed, the partial ordering selects the
more
constrained template as described by the rules in 14.10.3.

And since the first version of apply_odd_arguments is more specialized, it
should be selected before considering which version is more constrained.

/////////////////////////////////////////////////////////////////////
template <class Functor, class ArgumentFirst, class ArgumentSecond>             
  //requires true // works if uncommented                                       
decltype(auto) apply_odd_arguments(const Functor& functor,                      
                                   ArgumentFirst argument_first,                
                                   ArgumentSecond argument_second) {            
  return functor(argument_first);                                               
}                                                                               

template <class Functor, class ArgumentFirst, class ArgumentSecond,             
          class... ArgumentsRest>                                               
  requires sizeof...(ArgumentsRest) % 2 == 0                                    
decltype(auto) apply_odd_arguments(const Functor& functor,                      
                                   ArgumentFirst argument_first,                
                                   ArgumentSecond argument_second,              
                                   ArgumentsRest... arguments_rest) {           
  return apply_odd_arguments([&](auto... arguments) {                           
    return functor(argument_first, arguments...);                               
  }, arguments_rest...);                                                        
}                                                                               

int main() {                                                                    
  auto f = [](int i1, int i2) {                                                 
    return i1+i2;                                                               
  };                                                                            
  apply_odd_arguments(f, 1, 2, 3, 4);                                           
  return 0;                                                                     
}
/////////////////////////////////////////////////////////////////////


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]