In the following, struct Y overloads X's member function f. Both overloads are template functions, but take different arguments (typename and int), to be explicitly specified:
struct X
{
template static bool f() { return true;…
Is there an alternative to have some using-declarations in concept/constraint? Something like:
template
concept has_begin_v0 = requires (T t)
{
using std::begin; // KO
begin(t);
/*..*/
};
The possible ways I have found…
Per § 12.2.2.1 [over.match.funcs.general]/9-sentence-2:
A constructor inherited from class type C ([class.inhctor.init]) that
has a first parameter of type “reference to cv1 P” (including such a
constructor instantiated from a template) is excluded…
What is the reason which why this code compile :
#include
using namespace std;
class being {
public:
void running(char c) {
cout << "No one know ";
}
};
class human :public being {
public:
using being::running;
void…
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:
:4:12: error: reference to 'A' is ambiguous
4 | using enum A;
| …
Starting from this question:
Pointer derived from pure virtual class(A) can't access overload method from the pure class (B)
And considering this simplified code:
#include
#include
class Abstract
{
public:
virtual void…
This is not a question about the difference between using and typedef for creating type aliases. I would like to provide access to an existing type from a namespace inside a code block or a function.
I found two different ways :
I can "include" the…
I believe the new wording for [namespace.memdef]/1 tries to explain the conflict between the two declarations using M::g; and void g(); in namespace X, but I fail to understand the relationship between this new wording and the alluded conflict.
A…
Let's consider two classes A and B with the following interface:
class A {
public:
virtual void start() {} //default implementation does nothing
};
class B {
public:
void start() {/*do some stuff*/}
};
and then a third class which inherits…
Is the following program well-formed or ill-formed according to the c++ standard?
struct A { protected: static const int x = 0; };
struct B : A {};
struct C : A { using A::x; };
struct D : B, C {};
int main() { D::x; }
Different compilers gives…
Is the following program well-formed according to the c++ standard?
namespace X { class A; }
namespace Y { using X::A; class A {}; }
int main() {}
I'm getting different results with different compilers:
gcc compiles it without errors.
visual c++…
My friend has shown me the follow code
struct A {
virtual void f() = 0;
virtual void g() = 0;
};
struct AInternal : A {
virtual void f() { /* ... */ }
virtual void g() { /* ... */ }
};
He is using AInternal as an internal class that…
I have
namespace src {
struct src_bar;
void src_baz();
template class src_qux;
}
which I'd like to reference as
namespace dst {
struct dst_bar;
void dst_baz();
template class dst_qux;
}
meaning that I'd like…
I have a base class defining a constant and the child class can use it using alias. The construct is as below
class Base
{
protected:
static const int A_ = 1;
};
class Foo : public Base
{
private:
using Base::A_;
};
However, when I define…
Suppose I have two versions of operator-> (overloaded on const) in a base class. If I say
using Base::operator->;
in a derived class, will I get access to both versions or just the non-const one?