std::is_trivially_move_assignable in C++ with Examples

The std::is_trivially_move_assignable template of C++ STL is present in the <type_traits> header file. The std::is_trivially_move_assignable template of C++ STL is used to check whether the T is a trivially move assignable type or not. It return the boolean value true if T is trivially move assignable type, otherwise return false.

Header File:

#include<type_traits>

Template Class:

template <class T>
struct is_trivially_move_assignable;

Syntax:

std::is_trivially_move_assignable<T>::value

Parameter: The template std::is_trivially_move_assignable accepts a single parameter T(Trait class) to check whether T is trivially move assignable or not.



Return Value: The template std::is_trivially_move_assignable returns a boolean variable as shown below:

  • True: If the type T is a trivially move assignable.
  • False: If the type T is not a trivially move assignable.

Below is the program to demonstrate std::is_trivially_move_assignable in C++:

Program:

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ program to illustrate
// std::is_trivially_move_assignable
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;
  
// Declare Structures
class A {
};
  
struct B {
    B& operator=(B&&) = delete;
};
  
// Driver Code
int main()
{
  
    cout << boolalpha;
  
    cout << "int is_trivially_move_assignable? "
         << is_trivially_move_assignable<int>::value
         << endl;
  
    cout << "A is_trivially_move_assignable? "
         << is_trivially_move_assignable<A>::value
         << endl;
  
    cout << "B is_trivially_move_assignable? "
         << is_trivially_move_assignable<B>::value
         << endl;
  
    cout << "int[2] is triviallay move assignable? "
         << is_trivially_move_assignable<int[2]>::value
         << endl;
  
    return 0;
}

chevron_right


Output:

int is_trivially_move_assignable? true
A is_trivially_move_assignable? true
B is_trivially_move_assignable? false
int[2] is triviallay move assignable? false

Reference: http://www.cplusplus.com/reference/type_traits/is_trivially_move_assignable/

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.