Skip to main content
2 votes
2 answers
194 views

Im wondering if there is a better, more typesafe, way to return "a selection" than I do at the moment. If we only ever have one selected element at a time, we can just return a reference, ...
darune's user avatar
  • 11.5k
2 votes
1 answer
201 views

A std::reference_wrapper is guaranteed to be initialized (but can be rebound, unlike a normal reference). Being a wrapper class, what's the reason for std::reference_wrapper not to overload operator-&...
darune's user avatar
  • 11.5k
0 votes
2 answers
98 views

I have multiple child classes derived of a parent class. I would like to resolve one of the static fields of one of the child classes, based on a parameter that is unique across the children through a ...
Gábor DANI's user avatar
  • 2,135
1 vote
1 answer
234 views

I'm trying to learn the use of std::reference_wrapper and std::ref and the use cases of it. Here is a sample code I wrote. Please help me solve the compilation error. And it would be great if you can ...
Aman Kumar's user avatar
0 votes
1 answer
107 views

Consider following snippet: #include <bits/stdc++.h> using namespace std; int main() { int x=3; int y=1; int z=2; cout<<(&x)<<' '<<(&y)<<' '<&...
Rupa's user avatar
  • 110
0 votes
2 answers
174 views

(I'm mostly interested in a c++17 solution, even though you see me using std::unwrap_ref_decay; just imagine I've copied and pasted the possible implementation in my C++17 code. On the other hand, I'm ...
Enlico's user avatar
  • 30.3k
1 vote
1 answer
114 views

I have a function that accepts N position vectors and updates them: using Vector3r = Eigen::Matrix<Real, 3, 1, Eigen::DontAlign>; template<unsigned int N> using Vectorr = Eigen::Matrix<...
Sin3point14's user avatar
2 votes
2 answers
117 views

Trying to create a reference wrapper similar to std::reference_wrapper, but with possibility to call the methods of the wrapped object. #include <iostream> class A { public: void f() { ...
Israel Yankelovich's user avatar
2 votes
1 answer
550 views

What happens to a std::reference_wrapper if the reference used to create it goes out of scope? Can it still still provide access to the underlying object (which would still exist), or would it be ...
Chris's user avatar
  • 23
1 vote
1 answer
1k views

This question is related to std::expected and reference return type I try to get my head around std::expected (respectively https://github.com/TartanLlama/expected) as an alternative error handling ...
NeitherNor's user avatar
0 votes
2 answers
135 views

I have 2 classes lets say Class A and Class B, class A { public: A(B b); B GetB(); private: B b; }; class B { public: B(); void IncrementCounter(); int GetCounter(); ...
heyloo's user avatar
  • 37
0 votes
2 answers
107 views

I am working on my C++ home-project and got into trouble with the following C2676 error: binary '==': 'std::reference_wrapper<Interactable>' does not define this operator or a conversion to a ...
Sarungard's user avatar
3 votes
0 answers
483 views

std::reference_wrapper is a standard library that wraps a reference in a copyable, assignable object. My view is that it has a weird design and seems like a hack to trick classes that store objects by ...
alfC's user avatar
  • 16.8k
3 votes
3 answers
237 views

int main() { int x = 1; auto ref = std::ref(x); if (x < ref) { ... } } In the above code, I made an int variable and a reference_wrapper<int> variable, and then ...
Eunho Choi's user avatar
0 votes
0 answers
310 views

How to initialize a vector of reference_wrapper member variable in a class. I have tried to initialize with a vector in constructor initialisation_list. class Test { public: Test(std::...
Arun AC's user avatar
  • 417

15 30 50 per page
1
2 3 4 5
8