671 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
1
answer
274
views
Can I create an *alias* member function in C++?
I am refactoring a project, and I have to unify a set of derived classes under the same base class.
These are two derived classes:
class D1 : public virtual B {
virtual int F(int i) { ...
3
votes
1
answer
226
views
Why is `""s.size()` legal, but `5ms.count()` is not? [duplicate]
#include <chrono>
#include <string>
using namespace std::literals;
int main() {
""s.size(); // ok
(""s).size(); // ok
(5ms).count(); // ok
5ms....
0
votes
2
answers
143
views
Why can a const object call a non-const member function? [duplicate]
Consider the following code:
int main() {
auto const fn = [] mutable {};
fn(); // ok, why?
}
As per the latest C++ standard draft [expr.prim.lambda.closure] 7.5.6.2/6 (emphasis mine):
The ...
16
votes
3
answers
1k
views
For a member function, are constexpr, const reference return type, and const qualification mutually independent?
Using
g++ -std=gnu++17 -Werror -Wall -Wextra
the following code compiles without warning:
struct Mutable {
int x;
};
class State {
public:
constexpr const Mutable &Immutable() const {
...
5
votes
2
answers
116
views
How to simplify template member function definition?
I have a class that looks like this
template<class T, class THash, class TEqual, class TCompare>
class GraphT {
public:
typedef NodeT<T, THash, TEqual, TCompare> NodeInt;
typedef ...
1
vote
1
answer
149
views
Handling std::array of structures with std::function
could you please help me how to handle (initialize, call) std::array of structs of std::function. Code like below:
class A
{
struct Functions
{
std::function<bool()> handler1;
std::...
3
votes
1
answer
229
views
How to write a member function alias?
In modern C++ is it possible to write a member function alias with a syntax different from this:
class C {
int f(int a) { return ++a; }
inline int g(int a) { return f(a); }
};
I tried in a few ...
3
votes
1
answer
85
views
Can't call stored member function on stored object
I'm trying to create sort of an event system, I don't care if it is suboptimal, I'm doing it for fun. I do not want alternate solutions, I want to understand why this isn't working and how could I fix ...
2
votes
2
answers
71
views
Why don't I see implicitly generated member functions in the symbol table
Why don't I see implicitly generated constructors/destructor/ etc in the symbol table for my C++ code?
E.g
#include <iostream>
class Foo
{
public:
Foo (int N) : values {new int[N]}{
...
0
votes
1
answer
78
views
VBA class member function and class definition problem continues Vol 3
The story continues ... my earlier two questions were about the member functions fReadData and fReadData2
Public Function fReadData(alue As Range) As Double
pOne = alue.Cells(1)
fReadData = ...
0
votes
1
answer
56
views
VBA class member function and class definition problem continues
I send earlier question concerning class member function. Now I am facing a new problem, if the member function return value is a class where the function is defined.
The member function fReadData ...
0
votes
1
answer
57
views
VBA class member function and class definition problem
I am trying to make Excel VBA class member function fReadData which returns some values from the Excel spreadsheet and uses the class definition ClassOne, only for testing purposes.
' ClassOne
Option ...
1
vote
1
answer
128
views
How to replace ref-qualifiers of member functions with concept?
Is it possible to replace following ref-qualifiers with concepts?
That is, instead of
struct S
{
void func() && {}
void func() & {}
};
have something like this
struct S
{
void ...
2
votes
4
answers
168
views
Mapping enum class to function overload
Hi there I am facing the following problem: I have a class with many member functions of a certain pattern. Each of these member functions has 3 overloads and these overloads are the same for all ...
4
votes
1
answer
245
views
Explicit this member function use accepted by msvc but rejected by clang and gcc
I wrote the following program that compiles with msvc but rejected by clang and gcc. It uses explicit object member function. Demo.
#include <iostream>
struct C{
int f(this int);
};
...
user avatar
user20562802