Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9084015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:54:26+00:00 2026-06-16T20:54:26+00:00

struct A { enum InnerEnum { X }; A(InnerEnum x) {} }; int main()

  • 0
struct A
{
    enum InnerEnum { X };

    A(InnerEnum x)
    {}
};

int main()
{
    A a(X);
}

The compiler complains: error C2065: 'X' : undeclared identifier

The compiler knows what the constructor’s parameter type is, so when I pass X as the argument, the compiler should know it is a valid argument.

I know this is not ADL(Argument-dependent Name Lookup, also known as Koenig Lookup), but I think it’s useful and pretty handy. Because I don’t have to write as follows:

A a(A::X);

I think the ADL rule should be generalized to such a case.

Am I right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T20:54:28+00:00Added an answer on June 16, 2026 at 8:54 pm

    Function calls in C++ are subject to function overload resolution. Overload resolution is driven by the argument types. I.e. the language “works” specifically in that direction: from argument types to specific version of the function with the given name.

    You are proposing to introduce a reverse process – argument type deduction based on function name. This will not work in general case. It might work in cases when there’s only one candidate function (as in your example), but, again, in is contrary to principles that work in the general situation when the function is overloaded.

    Of course, the situation will get even more complicated when name lookup on unqualified name X can see something else named X in addition to your A::X. I think it can easily get very counterintuitive.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

template<int n> struct Numberim{ enum{ value = Numberim<n-1>::value + n }; }; template<> struct
template<unsigned int n> struct Factorial { enum { value = n * Factorial<n-1>::value}; };
Atm i have sth like that: template<int n> struct Pow { enum{val= Pow<n-1>::val<<1}; };
Please consider the following code. enum type {CONS, ATOM, FUNC, LAMBDA}; typedef struct{ enum
I have a following templated struct : template<int Degree> struct CPowerOfTen { enum {
Background Consider the following: template <unsigned N> struct Fibonacci { enum { value =
I have code: #include <cstdio> template<template<typename...> class> struct Foo { enum { n =
I have a class with a private member ( struct ) as follows: enum
After namespace , class , struct , enum , for , foreach , while
struct pointsto_val_def { unsigned int lhs; bitmap rhs; struct pointsto_val_def *next; }; typedef struct

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.