C++ std::is_copy_constructible














































C++ std::is_copy_constructible



Description:
The std::is_copy_constructible template of C++ STL .
copy constructible class is a class that has a default constructor  .
    
Syntax:
template <class T> struct is_copy_constructible;

Parameter:
It takes T as a complete type, or void , or an array of unknown bound.

Return Value: 
std::is_copy_constructible template returns a boolean value as shown below:

  • True: if the type is copy_constructible.
  • False: if the type is not copy_constructible.

Code:
#include <iostream> #include <type_traits> using namespace std;

struct class1 { }; struct class2 { class2(){} }; struct class3 { class3(int){} }; int main() { cout << boolalpha; cout << "is_default_constructible:" << endl; cout << "int: " << is_default_constructible<int>::value << endl; cout << "char: " << is_default_constructible<char>::value << endl; cout << "class1: " << is_default_constructible<class1>::value << endl; cout << "class2: " << is_default_constructible<class2>::value << endl; cout << "class3: " << is_default_constructible<class3>::value << endl; return 0; }

Output:
is_default_constructible: int: true char: true class1: true class2: true class3: false

More Articles of Mandeep Sheoran:

Name Views Likes
C++ program to insert an element into binary tree 6558 19
C++ program to find an element into binary tree 789 16
C++ std::is_void 589 15
C++ program to find the closest element in binary search tree 950 19
C++ program to replace every element with the least greater element on its right 590 12
C++ program to delete an element into binary tree 797 24
C++ program to find maximum element between two nodes of binary search tree 717 20
C++ std::remove_copy_if with std::vectors 562 11
C++ program to print duplicate elements from the binary search tree 3007 15
C++ program to find depth of the deepest odd level node in binary tree 588 23
C++ program to remove duplicate elements from the binary search tree 1659 20
C++ std::rotate_copy with std::vector 547 14
C++ std::copy_n with std::vector 654 22
C++ std::copy_if with std::vector 1600 18
C++ program to print all the elements of binary search tree 7562 22
C++ std::reverse_copy with std::list 615 18
C++ program to print all the elements of binary tree 1206 18
C++ program to print all full nodes in a binary tree 587 25
C++ program to find sink odd nodes in binary tree 594 15
C++ std::is_copy_assignable 617 22
C++ program to check whether a binary tree is a full binary tree or not using recursion 629 19
C++ std::is_copy_constructible 636 27
C++ program to delete an element into binary search tree 3047 18
C++ std::reverse_copy with std::vector 503 18
C++ std::rotate with std::vector 706 15
C++ program to check for symmetric binary tree using recursion 611 25
C++ program to maximum sum from a tree with adjacent levels not allowed 567 15
C++ std::copy_n with std::list 608 21
C++ program to check if two trees are identical using recursion 562 15
C++ std::copy_n 914 21
C++ std::copy_if with std::list 1066 19
C++ program to print the nodes at odd levels of a tree 580 13
C++ program to find lowest common ancestor in a binary tree 702 29
C++ program to find depth of the deepest odd level leaf node 509 13
C++ std::remove_copy_if with std::list 688 20
C++ program to add all greater values to every node in a given binary search tree 656 15

Comments