MCPcopy Create free account
hub / github.com/andreiavrammsd/cpp-channel / MovableOnly

Class MovableOnly

tests/channel_test.cpp:335–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333}
334
335class MovableOnly {
336 public:
337 explicit MovableOnly(int value) : value_{value} {}
338
339 MovableOnly() = default;
340
341 MovableOnly(const MovableOnly&)
342 {
343 std::cout << "Copy constructor should not be called";
344 std::abort();
345 }
346
347 MovableOnly(MovableOnly&& other) noexcept : value_{other.value_} { other.value_ = 0; }
348
349 MovableOnly& operator=(const MovableOnly& other)
350 {
351 if (this == &other) {
352 return *this;
353 }
354 std::cout << "Copy assignment should not be called";
355 std::abort();
356 }
357
358 MovableOnly& operator=(MovableOnly&& other) noexcept
359 {
360 if (this != &other) {
361 value_ = other.value_;
362 other.value_ = 0;
363 }
364
365 return *this;
366 }
367
368 int get_value() const { return value_; }
369
370 virtual ~MovableOnly() = default;
371
372 private:
373 int value_{0};
374};
375
376TEST(ChannelTest, Transform)
377{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected