C++ std::is_nothrow_copy_constructible














































C++ std::is_nothrow_copy_constructible



Description:
                  Is copy constructible throwing no exceptions

                       template <class T> struct is_nothrow_copy_constructible;

Trait class that identifies whether T is a copy constructible type, and such construction is known not to throw any exception.

Parameters:
T
              A complete type, or void , or an array of unknown bound.

Return value:
boolean i.e; true, false.

Example
#include <iostream> #include <type_traits> struct A { }; struct B { B(const B&){} }; struct C { C(const C&) noexcept {} }; int main() { std::cout << std::boolalpha; std::cout << "is_nothrow_copy_constructible:" << std::endl; std::cout << "int: " << std::is_nothrow_copy_constructible<int>::value << std::endl; std::cout << "A: " << std::is_nothrow_copy_constructible<A>::value << std::endl; std::cout << "B: " << std::is_nothrow_copy_constructible<B>::value << std::endl; std::cout << "C: " << std::is_nothrow_copy_constructible<C>::value << std::endl; return 0; }

/* OUTPUT: $g++ -std=c++11 -o main *.cpp $main is_nothrow_copy_constructible: int: true A: true B: false C: true */

 

More Articles of Nagendra Bhat:

Name Views Likes
C++ std::swap with std::array 547 20
C++ std::max_element with std::multiset 918 19
C++ std::min_element with std::list 621 17
C++ std::swap with std::vector 604 20
C++ program to diagonal sum of a binary tree 437 20
C++ std::max_element with std::list 733 18
C++ std::swap with std::deque 467 17
C++ Program to remove duplicate elements from std::list of char pointers 530 27
C++ std::iter_swap with std::list 659 17
C++ std::max_elemnt with std::set 411 14
C++ std::min_element with std::vector 683 17
C++ std::is_nothrow_move_assignable 412 13
C++ std::min_element with std::deque 1134 22
C++ std::is_nothrow_copy_constructible 542 25
std::min_element with std::multiset 1015 18
C++ std::make_heap with std::deque 1462 27
C++ std::max_element with std::array 538 20
C++ std::iter_swap with std::vector 479 16
C++ min_element with std::set 999 14
std::min_element with std::multiset 499 19
C++ std::iter_swap with std::deque 662 24
C++ std::max_element with std::forward_list 489 24
C++ std::min_element with std::array 586 22
C++ std::make_heap with std::vector 777 13
C++ std::make_heap with std::array 1381 21
C++ std::min_element with std::forward_list 456 19
C++ std::is_nothrow_default_constructible 520 24
C++ std::iter_swap with std::array 531 15
C++ std::max_element with std::vector 627 19
C++ std::swap with std::list 547 25
C++ program to convert a given binary tree to doubly linked list 443 14
C++ program to replace each node in binary tree with the sum of its inorder predecessor and successor 993 19
C++ thread std::thread::detach 700 19
C++ std::max_element with std::deque 5225 14

Comments