explicit-object-parameter Questions
1
Solved
In addition to an implicitly-defined copy assignment operator, if a class also defines an operator= without an lvalue-reference object parameter, which of the operators must be selected?
Please con...
Hermineherminia asked 3/8, 2024 at 20:27
1
Solved
Below is a recursive lambda expression that can compute the values of Fibonacci sequence both in runtime and during constant evaluation:
auto fib = [](this auto && f, auto && p) {
...
Dungaree asked 26/7, 2024 at 18:30
2
There was some code floating around on Reddit that defined a member-function with an explicit this object parameter defined as type int. This made me wonder how this member-function could possibly ...
Dodgem asked 10/7, 2024 at 23:17
1
I wrote the following program in C++23 that compiles with gcc and clang but is rejected by msvc. I want to know is this well-formed or ill-formed etc as per the standard. Live demo
struct C
{
void...
Gang asked 4/7, 2024 at 14:36
1
Solved
I recently noticed a strange issue regarding C++23 Deducing this feature.
Suppose we have a struct S with a simple conversion operator:
struct S {
operator int() { return 42; }
};
int i = S{};
S...
Virescent asked 28/1, 2024 at 11:55
1
Solved
How do I get the return type of a lambda that has a deducing this signature using std::invoke_result_t.
auto lambda = [](this auto& self, int x) -> int {
return x;
};
auto x = std::invok...
Handlebar asked 5/9, 2023 at 7:9
2
Solved
Is it possible to perfectly forward *this object inside member functions? If yes, then how can we do it? If no, then why not, and what alternatives do we have to achieve the same effect.
Please see...
Bevel asked 4/3, 2022 at 16:57
1
Solved
In C++23, deducing this is finally added to the standard.
Based on what I've read from the proposal, it opens up a new way of creating mixins, and possible to create recursive lambdas.
But I'm conf...
Limber asked 18/10, 2021 at 0:46
21
Solved
Let's say I have the following class X where I want to return access to an internal member:
class Z
{
// details
};
class X
{
std::vector<Z> vecZ;
public:
Z& Z(size_t index)
{
// ...
Principal asked 23/9, 2008 at 20:47
1
© 2022 - 2025 — McMap. All rights reserved.