Skip to main content
Stack Overflow
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
2 votes
1 answer
141 views

gcc, clang, and msvc all reject the following code: #include <memory> #include <vector> int main() { auto _ = std::vector<int const>{}; // error auto _ = std::vector<...
1 vote
1 answer
128 views

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 ...
0 votes
1 answer
89 views

If I understand this correctly, [over.load] doesn't exist in c++23, and so what I read in [over.load]/2.3 should not be true anymore, so this code struct Foo { int const& bar() const; int bar()...
3 votes
1 answer
275 views

Is the non ref-qualified overload of member-function f in accordance with the C++20 standard? Both Clang and GCC seem to accept it. Are they both pulling on the short end of the stick? What does the C+...
303's user avatar
  • 4,882
4 votes
1 answer
1k views

As I understand it, ref-qualified member-functions are used to distinguish between operating on an implicit this as an lvalue versus an rvalue. If we define a member function without the ref-...
2 votes
1 answer
110 views

These are the signatures, according to Cppreference: constexpr T& value() &; constexpr const T& value() const &; constexpr T&& value() &&; constexpr const T&& ...
3 votes
1 answer
291 views

I have this class: template<typename T, size_t N> class Array { private: T array[N]; public: template <typename... InitValues> constexpr Array(InitValues......
0 votes
1 answer
159 views

#include <string> struct S { std::string s_; std::string_view get() const & { return s_; } std::string_view get() const && = delete; }; // I can't ...
zrb's user avatar
  • 891
1 vote
1 answer
527 views

While answering another question, I noticed something peculiar about conversion operators when dealing with ref-qualifiers. Consider the following code: using P = std::unique_ptr<int>; struct A ...
2 votes
0 answers
123 views

Are there any use cases for std::vector::reserve() on an r-value std::vector, or is reserve() not l-value ref-qualified only because of backward compatibility?
3 votes
0 answers
154 views

Please, help me understand what's wrong with this piece of code: #include <string> #include <utility> class Sample { public: explicit Sample(std::string data): _data(std::move(...
0 votes
2 answers
93 views

The post here points out that std::string's member operator= is not lvalue ref-qualified. That allows us to write code such as this: std::string() = "Hello"; The linked post asks why this ...
7 votes
1 answer
240 views

In C++ one cannot overload in one class a member function with ref-qualifier with a member function without ref-qualifier. But at the same time it is possible to inherit one member function from a ...
1 vote
1 answer
142 views

Adding a ref-qualifier to an operator will remove the possibility to do rvalue assignment for example, compiling the following with g++ -std=c++14 bar.cpp && ./a.out #include <cstdio> ...
8 votes
1 answer
422 views

The following code causes undefined behaviour: class T { public: const std::string& get() const { return s_; } private: std::string s_ { "test" }; } void breaking() { const ...

15 30 50 per page
1
2 3 4

AltStyle によって変換されたページ (->オリジナル) /