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

I need a list of unique pointers to ints (I need the underlying int arrays because of MPI compatibility, they are buffers that are getting tracked for work done). I have a workaround but would like to ...
3 votes
2 answers
127 views

I had a usecase where I use a stack to process some data. Once processed, I want to output the data as a vector. But since underlying containers in stack are protected, it is now allowed to: stack<...
1 vote
1 answer
232 views

While checking &other != this is generally not a good idea in move/copy assignment and the copy-and-swap idiom should be preferred, is it allowed for a swap to perform such a check? Copy-and-swap ...
2 votes
2 answers
125 views

#include <fstream> #include <string> #include <vector> int main() { auto fin = std::ifstream("tmp.txt"); auto pos = std::istream_iterator<std::string>(fin);...
2 votes
1 answer
144 views

I'm studying std::move semantics and I would like this to be clarified to me: Say I have: // Message.h class Message { private: std::array<uint8_t, BUFFER_SIZE> buffer; std::queue<...
1 vote
2 answers
104 views

As far as I understand, std::invocable<callable_type,args_type...> treats the callable arguments as rvalue references to the types args_type. As a consequence, std::invocable<void(std::...
Oersted's user avatar
  • 3,914
5 votes
2 answers
183 views

Below is the most common implementation of std::swap: template<typename T> void std::swap(T& a, T& b) { auto tmp = std::move(a); a = std::move(b); b = std::move(...
4 votes
1 answer
119 views

clang-tidy reports the following piece of code as bugprone-use-after-move template <typename F, typename Tuple, size_t... I> auto transform_tuple_impl(F&& f, Tuple&& tuple, std::...
2 votes
0 answers
117 views

I'm experimenting, with wrapping move semantics into a wrapper type: #include <utility> #include <type_traits> // Type that will get moved struct NonDestructible { ~NonDestructible() =...
2 votes
2 answers
140 views

In C++, the value category of an expression is determined by two independent properties: Whether the expression has an identity Whether the expression can be moved from (References: cppreference and ...
3 votes
1 answer
95 views

I have an issue with clang-tidys recommendation Clang-tidy: arg is passed by value and only used once; consider moving it. So the code is essentially this: struct S{ kinda_heavy obj; S(...
6 votes
1 answer
471 views

Say I have a const T& version: template <typename T> void yetAnotherFunc( const T &input ) { // do something... } template <typename T> void myFunc( const T &input ) { ...
6 votes
1 answer
244 views

I'm experimenting with move semantics in C++, and I have a simple class Entity that should only be movable — copying is disabled. Here’s the class: class Entity { public: //... Entity() = ...
-1 votes
1 answer
70 views

This is not a solution to my problem. The suggested answer replaces the values with Nones. I quite literally require the size of my vector to reduce. MRE: use tokio::sync::mpsc; #[tokio::main] async ...
26 votes
3 answers
2k views

In the following code: struct copy_only { copy_only() = default; copy_only(const copy_only&) = default; copy_only& operator=(const copy_only&) = default; ...

15 30 50 per page
1
2 3 4 5
...
146

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