name-lookup Questions
1
Solved
In the context of a C++14 application, I use a scheme which could be resumed as follows (minimal reproducible test):
template <class Container>
struct LocateFunctions {
auto get_it() const...
Manolo asked 22/12, 2015 at 19:56
1
Solved
The following program is rejected by gcc as ambiguous:
struct Aint
{
virtual void foo(int);
};
struct Astring
{
virtual void foo(std::string);
};
struct A: public Aint, public Astring {};
i...
Gorky asked 22/12, 2015 at 14:3
0
After seeing this question When is a C++ template instantiation type checked? , and wondering myself for quite some time the same thing I started to play with code to assimilate the knowledge. The ...
Ethel asked 10/12, 2015 at 16:52
2
Solved
3.4 [basic.lookup]/p1
Overload resolution (13.3) takes place after name lookup has succeeded.
void g(long);
void g(int, int);
template<class T> void f() { g(0); }
void g(int, int = 0) {}...
Clubman asked 8/12, 2015 at 11:30
2
Solved
The following program
#include <algorithm>
#include <utility>
#include <memory>
namespace my_namespace
{
template<class T>
void swap(T& a, T& b)
{
T tmp = std::...
Brolly asked 3/12, 2015 at 20:39
1
Solved
As we know, the code below is ill-formed because the member x is in a dependent base class. However, changing x to this->x on the indicated line would fix the error.
template <typename T>...
Earthwork asked 19/9, 2015 at 6:47
1
Solved
I've just started learning D. In C++ there is :: (Scope resolution operator) to access global variable from the function if both global & local varible have same name. But how to do this in D l...
Lipophilic asked 4/8, 2015 at 10:40
2
Solved
Is the following program well-formed or ill-formed according to the c++ standard?
namespace N { int i; }
using namespace N;
using ::i;
int main() {}
I get different results with different compil...
Egotism asked 25/7, 2015 at 16:49
1
Solved
Consider the following program:
#include <iostream>
namespace N {
int j = 1;
}
namespace M {
typedef int N;
void f() {
std::cout << N::j << std::endl;
}
}
int main() { M:...
Lovesick asked 16/7, 2015 at 21:21
1
Solved
Consider the following code, that simulates a constexpr lambda (proposed for C++17, not available in C++14).
#include <iostream>
template<int M, class Pred>
constexpr auto fun(Pred p...
Gainless asked 13/6, 2015 at 14:29
1
As pointed out by ecatmur, this question already has an answer here.
This question is obviously not a duplicate of trailing return type using decltype with a variadic template function. It a...
Talbott asked 8/5, 2015 at 9:19
1
Solved
It's not allowed to put a namespace and a class with the same name into one declarative region, i.e.
namespace A {}
class A{};
is ill-formed (see §3.3.1/4). However, one can introduce the name o...
Carcinomatosis asked 26/4, 2015 at 21:48
1
Solved
I got recently bitten by (simplified)
struct Base {
typedef char T;
};
template<typename T>
struct Foo : Base {
T x[50]; // This is Base::T, not the template parameter
};
In other words...
Corkhill asked 31/3, 2015 at 7:5
3
Solved
Is there some way to force C++ compilers to perform name lookup for a given symbol during template instantiation (and not before)?
Given the following code:
template <class T>
auto wrapper(...
Shanly asked 28/1, 2015 at 7:52
1
Solved
When the compiler tries to resolve i.template hi<T>(); it finds hi in the global namespace instead of the method hi on i (ideone). Why?
#include <cstdio>
// Define 'hi' and 'bye' in t...
Mantling asked 13/1, 2015 at 19:56
2
Solved
Why code below well compiled in g++ but get error on clang?
#include <iostream>
class Object {};
class Print
{
public:
template <typename CharT>
inline friend std::basic_ostream<...
Naman asked 17/1, 2015 at 19:42
2
Solved
If I have a little bit of code like:
using namespace std;
namespace myNamespace
{
vector<float> sqrt( vector<float> v ) { return v; }
void func()
{
vector<float> myVec = { ...
Foilsman asked 19/11, 2014 at 15:2
3
Solved
This question is a furtherance of the one asked in this thread.
Using the following class definitions:
template <class T>
class Foo {
public:
Foo (const foo_arg_t foo_arg) : _foo_arg(foo_...
Bollay asked 13/7, 2009 at 17:11
2
Solved
Is the following example well-formed?
namespace N {
class A;
}
using namespace N;
class B {
int i;
friend class A;
};
namespace N {
class A {
B m;
int get() { return m.i; }
};
}
This ex...
Bonham asked 9/1, 2014 at 19:36
4
Solved
I try to find an element in a vector using overloaded operator==(). However, if using type1 in the following code, the output is 1 and 0 (not found). Using type2 gives both 1 and 1. The environment...
Broads asked 4/10, 2013 at 17:57
2
Solved
While I was searching for clues about a compilation problem I have had in my source, I have come across this bug report (against Mozilla's JavaScript engine source) related to functions lookup. Quo...
Bilodeau asked 15/7, 2013 at 18:31
1
Solved
EDIT: This is not a bug, just me not knowing about dependent name lookups in templated base classes (which MSVC "helpfully" resolves without errors).
I wrote a functor implementation a while bac...
Sob asked 9/5, 2013 at 21:8
1
Solved
With this sample program I observe a different behavior in g++ and clang
Foo.h:
#include <iostream>
namespace Bar
{
class Foo
{
public:
Foo(int x) : _x(x)
{}
int x() const
{
return...
Okubo asked 12/4, 2013 at 15:51
3
Solved
Is this a compiler-bug?
template <typename T>
T& operator++(T& t)
{
return t;
}
namespace asdf {
enum Foo { };
enum Bar { };
Foo& operator++(Foo& foo);
void fun()
{
Bar...
Adara asked 16/1, 2013 at 8:38
2
Solved
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'...
Tramontane asked 4/1, 2013 at 19:33
© 2022 - 2024 — McMap. All rights reserved.