C++14 polishing

This commit is contained in:
Oliver Kowalke 2015-11-30 20:13:18 +01:00
parent 53614539aa
commit ba6ea4b7a6
5 changed files with 43 additions and 59 deletions

View File

@ -160,7 +160,7 @@ pull_coroutine< T & >::control_block::control_block( context::preallocated pallo
}},
state{ state_t::unwind },
except{},
t( nullptr) {
t{ nullptr } {
// enter coroutine-fn in order to have first value available after ctor (of `*this`) returns
t = static_cast< T * >( ctx() );
}

View File

@ -52,10 +52,9 @@ public:
pull_coroutine( pull_coroutine &&) noexcept;
pull_coroutine & operator=( pull_coroutine && other) noexcept {
if ( this != & other) {
cb_ = other.cb_;
other.cb_ = nullptr;
}
if ( this == & other) return * this;
cb_ = other.cb_;
other.cb_ = nullptr;
return * this;
}
@ -69,9 +68,9 @@ public:
class iterator : public std::iterator< std::input_iterator_tag, typename std::remove_reference< T >::type > {
private:
pull_coroutine< T > * c_;
pull_coroutine< T > * c_{ nullptr };
void fetch_() {
void fetch_() noexcept {
BOOST_ASSERT( nullptr != c_);
if ( ! ( * c_) ) {
c_ = nullptr;
@ -90,11 +89,9 @@ public:
typedef typename iterator::pointer pointer_t;
typedef typename iterator::reference reference_t;
iterator() noexcept :
c_{ nullptr } {
}
constexpr iterator() noexcept = default;
explicit iterator( pull_coroutine< T > * c) :
explicit iterator( pull_coroutine< T > * c) noexcept :
c_{ c } {
fetch_();
}
@ -104,9 +101,8 @@ public:
}
iterator & operator=( iterator const& other) noexcept {
if ( this != & other) {
c_ = other.c_;
}
if ( this == & other) return * this;
c_ = other.c_;
return * this;
}
@ -166,10 +162,9 @@ public:
pull_coroutine( pull_coroutine &&) noexcept;
pull_coroutine & operator=( pull_coroutine && other) noexcept {
if ( this != & other) {
cb_ = other.cb_;
other.cb_ = nullptr;
}
if ( this == & other) return * this;
cb_ = other.cb_;
other.cb_ = nullptr;
return * this;
}
@ -183,9 +178,9 @@ public:
class iterator : public std::iterator< std::input_iterator_tag, typename std::remove_reference< T >::type > {
private:
pull_coroutine< T & > * c_;
pull_coroutine< T & > * c_{ nullptr };
void fetch_() {
void fetch_() noexcept {
BOOST_ASSERT( nullptr != c_);
if ( ! ( * c_) ) {
c_ = nullptr;
@ -204,11 +199,9 @@ public:
typedef typename iterator::pointer pointer_t;
typedef typename iterator::reference reference_t;
iterator() noexcept :
c_{ nullptr } {
}
constexpr iterator() noexcept = default;
explicit iterator( pull_coroutine< T & > * c) :
explicit iterator( pull_coroutine< T & > * c) noexcept :
c_{ c } {
fetch_();
}
@ -218,9 +211,8 @@ public:
}
iterator & operator=( iterator const& other) noexcept {
if ( this != & other) {
c_ = other.c_;
}
if ( this == & other) return * this;
c_ = other.c_;
return * this;
}
@ -278,10 +270,9 @@ public:
pull_coroutine( pull_coroutine &&) noexcept;
pull_coroutine & operator=( pull_coroutine && other) noexcept {
if ( this != & other) {
cb_ = other.cb_;
other.cb_ = nullptr;
}
if ( this == & other) return * this;
cb_ = other.cb_;
other.cb_ = nullptr;
return * this;
}

View File

@ -64,7 +64,7 @@ pull_coroutine< T >::~pull_coroutine() noexcept {
template< typename T >
pull_coroutine< T >::pull_coroutine( pull_coroutine && other) noexcept :
cb_( other.cb_) {
cb_{ other.cb_ } {
other.cb_ = nullptr;
}
@ -97,7 +97,7 @@ pull_coroutine< T >::get() noexcept {
template< typename T >
pull_coroutine< T & >::pull_coroutine( control_block * cb) noexcept :
cb_( cb) {
cb_{ cb } {
}
template< typename T >
@ -131,7 +131,7 @@ pull_coroutine< T & >::~pull_coroutine() noexcept {
template< typename T >
pull_coroutine< T & >::pull_coroutine( pull_coroutine && other) noexcept :
cb_( other.cb_) {
cb_{ other.cb_ } {
other.cb_ = nullptr;
}
@ -164,7 +164,7 @@ pull_coroutine< T & >::get() noexcept {
inline
pull_coroutine< void >::pull_coroutine( control_block * cb) noexcept :
cb_( cb) {
cb_{ cb } {
}
template< typename Fn >
@ -190,7 +190,7 @@ pull_coroutine< void >::~pull_coroutine() noexcept {
inline
pull_coroutine< void >::pull_coroutine( pull_coroutine && other) noexcept :
cb_( other.cb_) {
cb_{ other.cb_ } {
other.cb_ = nullptr;
}

View File

@ -50,10 +50,9 @@ public:
push_coroutine( push_coroutine &&) noexcept;
push_coroutine & operator=( push_coroutine && other) noexcept {
if ( this != & other) {
cb_ = other.cb_;
other.cb_ = nullptr;
}
if ( this == & other) return * this;
cb_ = other.cb_;
other.cb_ = nullptr;
return * this;
}
@ -67,12 +66,10 @@ public:
class iterator : public std::iterator< std::output_iterator_tag, void, void, void, void > {
private:
push_coroutine< T > * c_;
push_coroutine< T > * c_{ nullptr };
public:
iterator() noexcept :
c_{ nullptr } {
}
constexpr iterator() noexcept = default;
explicit iterator( push_coroutine< T > * c) noexcept :
c_{ c } {
@ -131,10 +128,9 @@ public:
push_coroutine( push_coroutine &&) noexcept;
push_coroutine & operator=( push_coroutine && other) noexcept {
if ( this != & other) {
cb_ = other.cb_;
other.cb_ = nullptr;
}
if ( this == & other) return * this;
cb_ = other.cb_;
other.cb_ = nullptr;
return * this;
}
@ -146,12 +142,10 @@ public:
class iterator : public std::iterator< std::output_iterator_tag, void, void, void, void > {
private:
push_coroutine< T & > * c_;
push_coroutine< T & > * c_{ nullptr };
public:
iterator() noexcept :
c_{ nullptr } {
}
constexpr iterator() noexcept = default;
explicit iterator( push_coroutine< T & > * c) noexcept :
c_{ c } {
@ -210,10 +204,9 @@ public:
push_coroutine( push_coroutine &&) noexcept;
push_coroutine & operator=( push_coroutine && other) noexcept {
if ( this != & other) {
cb_ = other.cb_;
other.cb_ = nullptr;
}
if ( this == & other) return * this;
cb_ = other.cb_;
other.cb_ = nullptr;
return * this;
}

View File

@ -53,7 +53,7 @@ push_coroutine< T >::~push_coroutine() noexcept {
template< typename T >
push_coroutine< T >::push_coroutine( push_coroutine && other) noexcept :
cb_( other.cb_) {
cb_{ other.cb_ } {
other.cb_ = nullptr;
}
@ -111,7 +111,7 @@ push_coroutine< T & >::~push_coroutine() noexcept {
template< typename T >
push_coroutine< T & >::push_coroutine( push_coroutine && other) noexcept :
cb_( other.cb_) {
cb_{ other.cb_ } {
other.cb_ = nullptr;
}
@ -160,7 +160,7 @@ push_coroutine< void >::~push_coroutine() noexcept {
inline
push_coroutine< void >::push_coroutine( push_coroutine && other) noexcept :
cb_( other.cb_) {
cb_{ other.cb_ } {
other.cb_ = nullptr;
}