3.4.1 Search for an unqualified name

In accordance with the C ++ standard: -

Name search rules apply evenly to all names (including typedef-names (7.1.3), namespace-names (7.3), concept names (14.9), concept map names (14.9.2), and the -names class (9.1)), where the grammar allows such names in the context discussed by a particular rule.

Do name lookup rules apply until overload resolution?

There must be some reason why I do not understand.

The following example is from a C ++ book in a nutshell: -

void func(int i)
{
  std::cout << "int: " << i << '\n';
}



namespace N 
{
  void func(double d)
  {
    std::cout << "double: " << std::showpoint << d << '\n';
  }

  void call_func(  )
  {
    // Even though func(int) is a better match, the compiler finds
    // N::func(double) first.
    func(3);
  }
}
+3
source share
3 answers

N.
func(), . , , , , .

.

(.. )

bob(double). , bob (double). , .

- bob(int) . . bob(5) bob(int) .

.

+9

. , . , , , . , else.

, , , , . acess , , .

, , .

+1

- . , " ",

https://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Fcplr315.htm Channel 9 http://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Core-C-/Stephan-T-Lavavej-Core-C-1-of-n.

, Overload-Resolution , , .

This search, based on the number of functional parameters, and then on the "implicit conversion sequence" is found in a set of pre-selected functions. If the call is to be resolved, f()this set contains all the functions with a name f()that are visible from a specific point in the code. This set is determined using the name search function.

0
source

Source: https://habr.com/ru/post/1762649/


All Articles