Questions tagged [unqualified-name]

A name that is relative to a declared context, eg just ArrayList (not java.util.ArrayList)

Analogous the a relative path in a filesystem, the name excluded the path of the containing/enclosing class, leaving just the name itself.

19 questions
23
votes
2 answers

Why does this template function not behave as expected?

I was reading about template functions and got confused by this problem: #include void f(int) { std::cout << "f(int)\n"; } template void g(T val) { std::cout << typeid(val).name() << " "; f(val); } void…
11
votes
5 answers

Unqualified name in Java

The teacher in our programming lessons is talking about "unqualified names", but I'm wondering what they really are. I suspect that things such as method names are unqualified, but I'm not certain. Is there anyone who can explain this to me? I need…
user4424299
6
votes
1 answer

Why doesn't `static_pointer_cast` work with ADL, but requires explicit `std::`?

Consider // https://godbolt.org/z/z5M9b9jzx #include #include struct B {}; struct D : B {}; int main() { std::shared_ptr b = std::make_shared(); auto d = static_pointer_cast(b); assert(d); } I'd've expected…
4
votes
1 answer

Which functions in standard C++ library should not be prefixed with std:: when used?

When I program in C++, instead of writing using namespace std;, I generally tend to use std:: prefixed components like std::cout, std::cin etc. But then I came across ADL and why you should use using std::swap;. Many components of the standard…
4
votes
1 answer

Overload resolution of a qualified name

Consider this function call: foo::bar(); 11.3.1.1.1, paragraph 3 [over.call.func] (N4778) covers this case: In unqualified function calls, the name is not qualified by an -> or . operator and has the more general form of a primary-expression. The…
4
votes
0 answers

C++ non-qualified lookup

I have the following code: //mystd plays a role of the std namespace //which does not allow any new overloads in it //so we define one in the global namespace namespace mystd { template struct A {}; } //if one uncomment this,…
3
votes
1 answer

Why must enum constants be unqualified in switch cases in java?

A bit of context. This is about the Problem with qualified enum names in switch cases like in the example: enum MyEnum { A, B, ; } switch(methodReturnungMyEnum()){ case MyEnum.A: // ... break case MyEnum.B: // ... …
Burdui
  • 1,242
  • 2
  • 10
  • 24
3
votes
2 answers

Is it possible to have a non-friend function which can only be found by ADL?

C++ has a feature, that in-class-defined friend functions can only be found by ADL (argument dependent lookup): struct Foo { friend void fn(Foo) { } // fn can only be called by ADL, it won't be found by other lookup methods }; Is it possible to…
geza
  • 28,403
  • 6
  • 61
  • 135
2
votes
3 answers

how to solve unqualified name lookup problem

I have the following simplified program: class Base { }; template < typename T > class X: public T { public: using TOP = T; }; // with dependent template parm template < typename T > class Y: public X< T > { // I have to write…
Klaus
  • 24,205
  • 7
  • 58
  • 113
1
vote
2 answers

Trying to sort map by values but get errors

I have this program with a map and i'm trying to sort them by values but i got errors. Can anyone tell me what I do wrong. Errors are at 28, 29, 30 line. Thanks #include #include #include #include #include…
Kent
  • 13
  • 3
1
vote
1 answer

It seems to me that there are two candidate functions for the call g(parm, 1) in the example in [basic.lookup.argdep]/3

Example in [basic.lookup.argdep]/3: namespace NS { class T { }; void f(T); void g(T, int); } NS::T parm; void g(NS::T, float); int main() { f(parm); // OK: calls NS::f extern void g(NS::T, float); g(parm, 1); // OK: calls…
1
vote
1 answer

error: expected unqualified-id before ‘const’

I have seen a few questions on this error, but I don't have much experience with making a class in C++, so I don't actually understand what the answers mean. I should also point out that I didn't write this code. I'm getting the error stated in the…
1
vote
3 answers

reference to array is ambiguous error when using memset function

I didn't understand why i take this "strange" error. I read similar questions but it didn't answer my questions. If i define the array inside main function rather than global scope, there is no error. But assume that i have to define this array in…
metis
  • 1,024
  • 2
  • 10
  • 26
0
votes
1 answer

C++, conflicting between library function and inhertited class function

#include #include using namespace std; class A{ public: bool close(){ return true; } }; class B: public A{ public: void fun(){ (void) close(1); } }; int main() { B b; …
R_S
  • 11
  • 3
0
votes
2 answers

Stored procedures with unqualified table names not working with Babelfish

I have created a Babelfish-enabled Postgres database in RDS. I connected with SSMS and created a Database named 'demo'. Within 'demo' I created a Schema named 'biz'. I created my tables and stored procedures in the 'biz' schema. The stored…
1
2