Skip to content

Instantly share code, notes, and snippets.

@LucianoPAlmeida
Last active December 2, 2021 01:23
Show Gist options
  • Save LucianoPAlmeida/8d8962846490f9afdf3ab14c36b855f3 to your computer and use it in GitHub Desktop.
Save LucianoPAlmeida/8d8962846490f9afdf3ab14c36b855f3 to your computer and use it in GitHub Desktop.
#include <string>
#include <utility>
#include <iostream>
class A {
int member{};
public:
~A() {}; // User defined destructor;
};
class B {
int member{};
public:
B(const B &obj) {} // User defined copy constructor
};
class C {
int member{};
};
int main() {
std::cout << "A: " << std::is_trivially_move_constructible<A>::value << std::endl;
// A: 0 since A has an user-defined destructor.
std::cout << "B: " << std::is_trivially_move_constructible<B>::value << std::endl;
// B: 0 since B has an user-defined copy-constructor.
std::cout << "C: " << std::is_trivially_move_constructible<C>::value << std::endl;
// C: 1 all the rules for generating an implicit move are satisfied.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment