name-lookup Questions
2
Solved
I'm writing some type traits to see if a free function exists with a specific set of parameters. The functions have a signature that looks something like this:
template <class T> void func( ...
Cockrell asked 17/3, 2014 at 20:5
4
I have a problem with the following code:
Generator.h:
#pragma once
class Generator
{
public:
friend class BagObject;
Generator(void);
~Generator(void);
...
void generator(int);
private:
Bag...
Constrain asked 14/11, 2016 at 17:51
1
Solved
I am looking at someone else's C++ code (note I am not fluent in C++).
Within the class, there is this member function:
void ClassYaba::funcname()
{
...
::foo();
...
}
There is no member functi...
Townshend asked 14/6, 2022 at 22:15
1
Solved
namespace N {
struct A {};
template<typename T>
constexpr bool operator<(const T&, const T&) { return true; }
}
constexpr bool operator<(const N::A&, const N::A&) ...
Uncloak asked 5/3, 2022 at 15:11
5
Solved
Is there a particularly good reason to choose to use an elaborated type specifier? For example, in certain circumstances, one is required to use the template or typename keywords to disambiguate a ...
Backhand asked 5/6, 2012 at 18:7
1
Solved
Consider the following demonstrative program.
#include <iostream>
namespace N
{
struct A
{
static int n;
};
A A;
}
int N::A::n = 10;
int main()
{
std::cout << N::A::n <&l...
Apeak asked 7/5, 2021 at 13:30
2
Solved
Consider following code snippet with C++20 using-enum-declaration:
namespace A { enum A {}; };
using namespace A;
using enum A;
gcc-trunk rejects it with:
<source>:4:12: error: reference to...
Siriasis asked 14/4, 2021 at 17:38
1
Solved
struct A{
template<typename U>
void T(){}
};
struct B{
template<typename U>
struct T{
using type = U;
};
};
struct C:A,B{
};
int main(){
C::T<int>::type d;
}
This example...
Orola asked 26/2, 2021 at 9:18
1
All students are surprised by the behavior of C++ using-directives. Consider this snippet (Godbolt):
namespace NA {
int foo(Zoo::Lion);
}
namespace NB {
int foo(Zoo::Lion);
namespace NC {
names...
Fowling asked 19/12, 2020 at 0:53
2
Solved
Actually, the below code can not be compiled with Clang using this command:
clang++ -std=c++11 test.cc -o test.
I just want to mimic the same behavior as "swapping idiom" in C++ to use &q...
Ragan asked 20/8, 2020 at 6:12
0
When a function body is instantiated, dependent function call overload resolution should find the best match in associated namespace through ADL, otherwise the behavior is undefined, [temp.dep.cand...
Dementia asked 26/7, 2020 at 20:9
1
Solved
I have read the standard section of [basic.lookup.unqual] and I am confused about this:
typedef int f;
namespace N {
struct A {
friend void f(A &);
operator int();
void g(A a) {
int i = ...
Melly asked 23/4, 2020 at 3:39
2
Solved
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 f...
Nardi asked 20/2, 2020 at 9:53
1
Solved
I'm using Visual C++, If I compile this code:
class A {};
class B : private A {};
class C : public B
{
void func()
{
A a{};
}
};
I get this error:
error C2247: 'A' not accessible be...
Freezing asked 15/2, 2020 at 10:0
2
I was reading about template functions and got confused by this problem:
#include <iostream>
void f(int) {
std::cout << "f(int)\n";
}
template<typename T>
void g(T val) {
std...
Polar asked 29/11, 2019 at 6:2
3
Solved
This question got me wondering whether it is ever useful/necessary to fully qualify class names (including the global scope operator) in an out-of-class member function definition.
On the one hand...
Markusmarl asked 18/11, 2019 at 12:4
2
Solved
In this example, classes Foo and Bar are provided from a library. My class Baz inherits from both.
struct Foo
{
void do_stuff (int, int);
};
struct Bar
{
virtual void do_stuff (float) = 0;
};
...
Altissimo asked 4/11, 2019 at 17:12
1
Solved
What is the meaning of the highlighted sentence below? Does it have anything to do with function templates?
[over.load]/1:
Not all function declarations can be overloaded. Those that cannot be...
Celebrant asked 15/7, 2019 at 14:44
2
Solved
I stumbled on this the other day and can't figure out which answer is correct, or whether both are acceptable.
Specifically, I'm referring to the call to bar(T{}) in OtherFunction. From what I've...
Uncinate asked 8/6, 2019 at 1:3
1
Solved
I have the following code which defines size_t equivalent to std::size_t and ::size_t if I included <cstddef>.
// h.hpp
namespace N {
using size_t = decltype(sizeof(int));
}
// a.hpp
#inc...
Xe asked 11/4, 2019 at 7:25
2
Solved
Compiling the following code fails because the second function can't find the first one, even though it's outside namespaces. I couldn't figure out the problem myself, and so far I haven't found an...
Gable asked 22/2, 2019 at 14:31
2
Solved
I've defined an operator<< output function for std::pair instances, for use by some unit tests that want to print the values if they don't watch what's expected. My test code also has pairs t...
Tletski asked 22/2, 2019 at 5:17
2
Solved
If name in C++ is not fully qualified, e.g. std::cout, it can lead to an unintentional error, such as mentioned at https://en.cppreference.com/w/cpp/language/qualified_lookup. But using a fully qua...
Individuality asked 17/2, 2019 at 10:4
4
Solved
What part of the C++ specification restricts argument dependent lookup from finding function templates in the set of associated namespaces? In other words, why does the last call in main below fail...
Mima asked 1/6, 2010 at 22:0
1
Solved
I am getting an issue compiling this minimal example with g++ 7.3
template<typename T>
struct conflict
{
};
template<typename T>
struct s
{
int conflict;
};
template<typename T&g...
Blackleg asked 5/12, 2018 at 19:8
1 Next >
© 2022 - 2024 — McMap. All rights reserved.