Created
December 19, 2014 19:56
-
-
Save orlp/41dbdbc0871bf4aa672e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iterator> | |
#include <type_traits> | |
template<class Iterator> | |
using move_if_noexcept_iterator = typename std::conditional< | |
!std::is_nothrow_move_constructible< | |
typename std::iterator_traits<Iterator>::value_type | |
>::value && std::is_copy_constructible< | |
typename std::iterator_traits<Iterator>::value_type | |
>::value, | |
Iterator, | |
std::move_iterator<Iterator> | |
>::type; | |
template<class Iterator> | |
constexpr move_if_noexcept_iterator<Iterator> make_move_if_noexcept_iterator(Iterator i) { | |
return move_if_noexcept_iterator<Iterator>(i); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment