cplusplus / cplusplus/draft

[namespace.udecl] How to consider the properties of an object parameter in the context other than overload resolution

Open
#5,439 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

[namespace.udecl] p11 says

The set of declarations named by a using-declarator that inhabits a class C does not include member functions and member function templates of a base class that correspond to (and thus would conflict with) a declaration of a function or function template in C.

According to [basic.scope.scope] p4, which requires they have corresponding object parameters. Although, we have specified the type of implicit object parameter in [over.match.funcs.general] p4, that says

For conversion functions that are implicit object member functions, the function is considered to be a member of the class of the implied object argument for the purpose of defining the type of the implicit object parameter. For non-conversion functions that are implicit object member functions nominated by a using-declaration in a derived class, the function is considered to be a member of the derived class for the purpose of defining the type of the implicit object parameter.

However, such a source transformation and construction are only used in overload resolution, as per [over.match.funcs.general] p1

The source transformations and constructions defined in these subclauses are only for the purpose of describing the overload resolution process.

Consider this example:

struct Base{
   void show(int);
};
struct Derived:Base{
   using Base::show;
   void show(int);
};

How to consider the properties of the object parameter of B::show in this context? Maybe, we should append the following rule

consider the member functions and member function templates of the base class are members of the derived class if the members have implicit object parameters.

The determination of the type of an implicit object parameter should be moved from [over] as a common rule?


whether the constructors have object parameters when comparing whether they correspond?

[dcl.fct] p8 says

The object parameter of a non-static member function is either the explicit object parameter or the implicit object parameter ([over.match.funcs]).

A constructor is a non-static member function, the rule says a constructor should have an object parameter. Although, [over.match.funcs.general] p2 says

For the purposes of overload resolution, both static and non-static member functions have an object parameter, but constructors do not.

Again, the rule is just applied in the overload resolution. Consider this example:

struct Base1{
   Base1(int);
};
struct Derived1:Base1{
   using Base1::Base1;
   Derived(int);
};

Is [namespace.udecl] p11 suitable for this case? Furthermore, Do such two constructors correspond?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with [namespace.udecl] p11, [basic.scope.scope] p4, [over.match.funcs.general] p1–p4, and [dcl.fct] p8. Compare the Base/Derived using-declaration examples, including the constructor case, and determine whether the existing rules define corresponding object parameters outside overload resolution. Done means the standard wording or interpretation resolves both the member-function and constructor questions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.