name-lookup Questions
7
Solved
I'm trying to define base class, which contains typedef's only.
template<typename T>
class A
{
public:
typedef std::vector<T> Vec_t;
};
template<typename T>
class B : public ...
Tavis asked 29/10, 2009 at 11:21
1
Solved
The following code:
struct X {
X() {}
};
struct Y {
Y() {}
Y(X) {}
Y(int) {}
friend bool operator==(const Y&, const Y&) { return false; }
};
bool f()
{
return 1 == X();
}
fails t...
Caesarean asked 28/8, 2018 at 23:33
1
Solved
Basically I want to have multiple member functions with same name, but different signature, spread in multiple base classes.
Example:
#include <iostream>
struct A
{
void print(int) { std:...
Monte asked 4/8, 2018 at 23:47
1
Solved
In the c++ standard [temp.point] it is written:
The instantiation context of an expression that depends on the
template arguments is the set of declarations with external linkage
declared prio...
Faunus asked 22/7, 2018 at 12:47
1
Solved
The following very simple code won't compile
#include <vector>
#include <string>
namespace Foobar {
struct Test {
std::string f;
std::uint16_t uuid;
};
}
bool operator==(const F...
Slowpoke asked 20/7, 2018 at 17:44
3
Solved
Let us define f, as a friend function of S, inside the declaration of S:
struct S
{
friend void f() {}
};
I cannot find a way to call f.
Is it true, then, that such an inline friend function c...
Endmost asked 12/7, 2018 at 11:31
1
Solved
Consider this code:
namespace A
{
int i = 24;
}
namespace B
{
using namespace A;
int i = 11;
int k = i; // finds B::i, no ambiguity
}
And basic.lookup.unqual.2:
§6.4.1 Unqualified name ...
Solicitous asked 20/1, 2018 at 18:48
1
Solved
namespace libzerocoin {
//Commitment class
Commitment::Commitment::Commitment(const IntegerGroupParams* p,
const Bignum& value): params(p), contents(value) {
this->randomness = Bignum::ran...
Underarm asked 30/11, 2017 at 13:50
2
Solved
What is the fully qualified name of a friend function defined inside of a class?
I recently saw an example analogous to the following. What is the fully qualified name of val() below?
#include &l...
Omniscience asked 6/11, 2017 at 11:40
2
Solved
Why does the following code compile:
template<typename T>
void foo(T in) { bar(in); }
struct type{};
void bar(type) {}
int main() { foo(type()); }
When the following does not:
template&l...
Subserve asked 15/9, 2017 at 14:38
1
#include <stdio.h>
#include <cstddef>
#include <cstring>
namespace /*namespace name generated by compiler*/
{
struct BB{};
}
struct AA{};
namespace my
{
inline void * memcpy(...
Volatilize asked 16/8, 2017 at 12:33
1
Solved
I've been struggling with a compilation issue, and have been able to shrink the problem down to a small code segment.
To set the stage, I'm trying to do CRTP, where the base method calls another i...
Dillard asked 5/8, 2017 at 6:15
1
from temp.local :
In the definition of a member of a class template that appears outside
of the class template definition, the name of a member of the class
template hides the name of a templa...
Maxey asked 24/12, 2016 at 13:10
1
Solved
I'm using Visual Studio 2015.
Any idea why this code compiles:
#include <memory>
class Foo;
class Bar;
typedef std::pair<Foo*,std::weak_ptr<Bar>> Object;
typedef std::vector<...
Swanherd asked 4/7, 2017 at 10:12
2
Solved
This code compiles with MSVC 2015, but doesn't compile with Clang 5.0.0 (trunk 304874):
template <typename T>
struct Base
{
T data;
};
template <typename T>
struct Derived : Base<...
Freudberg asked 7/6, 2017 at 15:29
3
Solved
Today while writing some especially terrible code, I stumbled across this mysterious behavior. The Python 3 program below prints a randomly selected attribute of object. How does this happen?
An o...
Starr asked 21/5, 2017 at 1:27
3
Solved
The snippet below compiles (demo):
struct A{ int i = 10; };
int main() {
struct A{ int i = 20; };
struct A;
struct A a;
}
But this doesn't:
struct A{ int i = 10; };
int main() {
// struct ...
Purely asked 4/1, 2017 at 19:5
1
Solved
Let's say I have a template function:
template <class T>
void tfoo( T t )
{
foo( t );
}
later I want to use it with a type, so I declare/define a function and try to call it:
void foo( i...
Penelopepeneplain asked 29/11, 2016 at 20:45
2
Solved
Consider this code:
#include <iostream>
namespace N {
class A {};
void f(A a) { std::cout << "N::f\n"; }
}
void f(int i) { std::cout << "::f\n"; }
template <typename T>...
Cowles asked 30/8, 2016 at 12:51
2
Solved
please see the following code
struct A { using type = int; };
struct B : private A {};
struct C : B { using base_type = A; };
All of gcc 6.1, clang 3.8, and msvc 2015 update 3 refuse to compile ...
Caesarea asked 4/7, 2016 at 8:13
3
Solved
Consider the following snippet:
struct Base { };
struct Derived : Base { };
void f(Base &) { std::cout << "f(Base&)\n"; }
template <class T = int>
void g() {
Derived d;
f(T...
Maniple asked 1/6, 2016 at 8:48
2
Solved
Consider this code:
using type = long;
namespace n {
using type = long;
}
using namespace n;
int main() {
type t;
}
This compiles cleanly on Clang 3.7 and GCC 5.3, but MSVC 19* gives the fol...
Byandby asked 24/3, 2016 at 15:53
2
Solved
One of the weirder corner cases of C is that functions can be declared within other functions, e.g.
void foo(void)
{
void bar(void); // Behaves as if this was written above void foo(void)
bar();...
Atilt asked 22/3, 2016 at 9:20
2
Solved
I've got a real situation which can be summarized in the following example:
template< typename ListenerType >
struct Notifier
{
void add_listener( ListenerType& ){}
};
struct TimeListe...
Ruffian asked 8/3, 2016 at 17:29
2
Solved
Ran into an interesting issue today and am trying to understand why.
Consider the following:
class Base
{
public:
Base(){}
~Base(){}
static void function1(){}
void function2()
{
int functio...
Aenea asked 19/1, 2016 at 21:17
© 2022 - 2024 — McMap. All rights reserved.