From 7a702c4e86347d50f04a8768ff2c4832777e2d57 Mon Sep 17 00:00:00 2001 From: Saliya Hamparawa Date: Wed, 20 Dec 2017 11:09:38 +0530 Subject: [PATCH 1/8] Fixing a resource leak in move assignment Signed-off-by: Saliya Hamparawa --- include/boost/coroutine2/detail/pull_coroutine.hpp | 3 +-- include/boost/coroutine2/detail/push_coroutine.hpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/boost/coroutine2/detail/pull_coroutine.hpp b/include/boost/coroutine2/detail/pull_coroutine.hpp index 32cd68e..ab90b60 100644 --- a/include/boost/coroutine2/detail/pull_coroutine.hpp +++ b/include/boost/coroutine2/detail/pull_coroutine.hpp @@ -56,8 +56,7 @@ public: pull_coroutine & operator=( pull_coroutine && other) noexcept { if ( this == & other) return * this; - cb_ = other.cb_; - other.cb_ = nullptr; + std::swap(cb_, other.cb_); return * this; } diff --git a/include/boost/coroutine2/detail/push_coroutine.hpp b/include/boost/coroutine2/detail/push_coroutine.hpp index d152be2..4b183a7 100644 --- a/include/boost/coroutine2/detail/push_coroutine.hpp +++ b/include/boost/coroutine2/detail/push_coroutine.hpp @@ -54,8 +54,7 @@ public: push_coroutine & operator=( push_coroutine && other) noexcept { if ( this == & other) return * this; - cb_ = other.cb_; - other.cb_ = nullptr; + std::swap(cb_, other.cb_); return * this; } From a3eb60c432c58a9dcf2c24af0082a4548c8b5698 Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Wed, 20 Dec 2017 06:21:48 +0000 Subject: [PATCH 2/8] Update pull_coroutine.hpp --- include/boost/coroutine2/detail/pull_coroutine.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/boost/coroutine2/detail/pull_coroutine.hpp b/include/boost/coroutine2/detail/pull_coroutine.hpp index ab90b60..823ca64 100644 --- a/include/boost/coroutine2/detail/pull_coroutine.hpp +++ b/include/boost/coroutine2/detail/pull_coroutine.hpp @@ -167,8 +167,7 @@ public: pull_coroutine & operator=( pull_coroutine && other) noexcept { if ( this == & other) return * this; - cb_ = other.cb_; - other.cb_ = nullptr; + std::swap(cb_, other.cb_); return * this; } @@ -277,8 +276,7 @@ public: pull_coroutine & operator=( pull_coroutine && other) noexcept { if ( this == & other) return * this; - cb_ = other.cb_; - other.cb_ = nullptr; + std::swap(cb_, other.cb_); return * this; } From 6bf49d619acab948f9b9eb46f8f08d48f6748c75 Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Wed, 20 Dec 2017 06:22:27 +0000 Subject: [PATCH 3/8] Update push_coroutine.hpp --- include/boost/coroutine2/detail/push_coroutine.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/boost/coroutine2/detail/push_coroutine.hpp b/include/boost/coroutine2/detail/push_coroutine.hpp index 4b183a7..45ae170 100644 --- a/include/boost/coroutine2/detail/push_coroutine.hpp +++ b/include/boost/coroutine2/detail/push_coroutine.hpp @@ -133,8 +133,7 @@ public: push_coroutine & operator=( push_coroutine && other) noexcept { if ( this == & other) return * this; - cb_ = other.cb_; - other.cb_ = nullptr; + std::swap(cb_, other.cb_); return * this; } @@ -211,8 +210,7 @@ public: push_coroutine & operator=( push_coroutine && other) noexcept { if ( this == & other) return * this; - cb_ = other.cb_; - other.cb_ = nullptr; + std::swap(cb_, other.cb_); return * this; } From b0b22e16e96dba5b3445b1a1a08ac52ce32f286f Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Wed, 20 Dec 2017 06:23:22 +0000 Subject: [PATCH 4/8] Update push_coroutine.hpp --- include/boost/coroutine2/detail/push_coroutine.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/coroutine2/detail/push_coroutine.hpp b/include/boost/coroutine2/detail/push_coroutine.hpp index 45ae170..e68c880 100644 --- a/include/boost/coroutine2/detail/push_coroutine.hpp +++ b/include/boost/coroutine2/detail/push_coroutine.hpp @@ -54,7 +54,7 @@ public: push_coroutine & operator=( push_coroutine && other) noexcept { if ( this == & other) return * this; - std::swap(cb_, other.cb_); + std::swap( cb_, other.cb_); return * this; } @@ -133,7 +133,7 @@ public: push_coroutine & operator=( push_coroutine && other) noexcept { if ( this == & other) return * this; - std::swap(cb_, other.cb_); + std::swap( cb_, other.cb_); return * this; } @@ -210,7 +210,7 @@ public: push_coroutine & operator=( push_coroutine && other) noexcept { if ( this == & other) return * this; - std::swap(cb_, other.cb_); + std::swap( cb_, other.cb_); return * this; } From 98e7406a40f52dbd7bd17bf9bb5e301775ab207a Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Wed, 20 Dec 2017 06:23:59 +0000 Subject: [PATCH 5/8] Update pull_coroutine.hpp --- include/boost/coroutine2/detail/pull_coroutine.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/coroutine2/detail/pull_coroutine.hpp b/include/boost/coroutine2/detail/pull_coroutine.hpp index 823ca64..928a477 100644 --- a/include/boost/coroutine2/detail/pull_coroutine.hpp +++ b/include/boost/coroutine2/detail/pull_coroutine.hpp @@ -56,7 +56,7 @@ public: pull_coroutine & operator=( pull_coroutine && other) noexcept { if ( this == & other) return * this; - std::swap(cb_, other.cb_); + std::swap( cb_, other.cb_); return * this; } @@ -167,7 +167,7 @@ public: pull_coroutine & operator=( pull_coroutine && other) noexcept { if ( this == & other) return * this; - std::swap(cb_, other.cb_); + std::swap( cb_, other.cb_); return * this; } @@ -276,7 +276,7 @@ public: pull_coroutine & operator=( pull_coroutine && other) noexcept { if ( this == & other) return * this; - std::swap(cb_, other.cb_); + std::swap( cb_, other.cb_); return * this; } From 50f8ae30d16305d53198df5ba8d8c61e51720ae0 Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Wed, 20 Dec 2017 07:38:55 +0100 Subject: [PATCH 6/8] Fixing a resource leak in move copy ctor --- include/boost/coroutine2/detail/pull_coroutine.ipp | 12 ++++++------ include/boost/coroutine2/detail/push_coroutine.ipp | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/boost/coroutine2/detail/pull_coroutine.ipp b/include/boost/coroutine2/detail/pull_coroutine.ipp index 699d5ab..6a2f6ed 100644 --- a/include/boost/coroutine2/detail/pull_coroutine.ipp +++ b/include/boost/coroutine2/detail/pull_coroutine.ipp @@ -67,8 +67,8 @@ pull_coroutine< T >::~pull_coroutine() { template< typename T > pull_coroutine< T >::pull_coroutine( pull_coroutine && other) noexcept : - cb_{ other.cb_ } { - other.cb_ = nullptr; + cb_{ nullptr } { + std::swap( cb_, other.cb_); } template< typename T > @@ -136,8 +136,8 @@ pull_coroutine< T & >::~pull_coroutine() { template< typename T > pull_coroutine< T & >::pull_coroutine( pull_coroutine && other) noexcept : - cb_{ other.cb_ } { - other.cb_ = nullptr; + cb_{ nullptr } { + std::swap( cb_, other.cb_); } template< typename T > @@ -197,8 +197,8 @@ pull_coroutine< void >::~pull_coroutine() { inline pull_coroutine< void >::pull_coroutine( pull_coroutine && other) noexcept : - cb_{ other.cb_ } { - other.cb_ = nullptr; + cb_{ nullptr } { + std::swap( cb_, other.cb_); } inline diff --git a/include/boost/coroutine2/detail/push_coroutine.ipp b/include/boost/coroutine2/detail/push_coroutine.ipp index dd51403..dedfa42 100644 --- a/include/boost/coroutine2/detail/push_coroutine.ipp +++ b/include/boost/coroutine2/detail/push_coroutine.ipp @@ -56,8 +56,8 @@ push_coroutine< T >::~push_coroutine() { template< typename T > push_coroutine< T >::push_coroutine( push_coroutine && other) noexcept : - cb_{ other.cb_ } { - other.cb_ = nullptr; + cb_{ nullptr } { + std::swap( cb_, other.cb_); } template< typename T > @@ -116,8 +116,8 @@ push_coroutine< T & >::~push_coroutine() { template< typename T > push_coroutine< T & >::push_coroutine( push_coroutine && other) noexcept : - cb_{ other.cb_ } { - other.cb_ = nullptr; + cb_{ nullptr } { + std::swap( cb_, other.cb_); } template< typename T > @@ -167,8 +167,8 @@ push_coroutine< void >::~push_coroutine() { inline push_coroutine< void >::push_coroutine( push_coroutine && other) noexcept : - cb_{ other.cb_ } { - other.cb_ = nullptr; + cb_{ nullptr } { + std::swap( cb_, other.cb_); } inline From 3e074ab9dca22d31f3d3bf74e7acb22e1046ef43 Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Wed, 20 Dec 2017 15:34:05 +0100 Subject: [PATCH 7/8] add control file for Travis CI --- .travis.yml | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..29274b7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,119 @@ +# Copyright 2016, 2017 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) + +language: cpp + +sudo: false + +python: "2.7" + +branches: + only: + - master + - develop + - /feature\/.*/ + +env: + matrix: + - BOGUS_JOB=true + +matrix: + + exclude: + - env: BOGUS_JOB=true + + include: + - os: linux + compiler: g++ + env: TOOLSET=gcc COMPILER=g++ CXXSTD=11 + + - os: linux + compiler: g++-5 + env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=11,14,1z + addons: + apt: + packages: + - g++-5 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-6 + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=11,14,1z + addons: + apt: + packages: + - g++-6 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-7 + env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=11,14,17 + addons: + apt: + packages: + - g++-7 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11 + + - os: linux + compiler: clang++-4.0 + env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=11,14,1z + addons: + apt: + packages: + - clang-4.0 + - libstdc++-6-dev + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-4.0 + + - os: linux + compiler: clang++-5.0 + env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=11,14,1z + addons: + apt: + packages: + - clang-5.0 + - libstdc++-7-dev + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-5.0 + + - os: osx + osx_image: xcode8.3 + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + + - os: osx + osx_image: xcode9.1 + compiler: clang++ + env: TOOLSET=clang COMPILER=clang++ CXXSTD=11,14,1z + +install: + - BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true + - cd .. + - git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root + - cd boost-root + - git submodule update --init tools/build + - git submodule update --init libs/config + - git submodule update --init tools/boostdep + - cp -r $TRAVIS_BUILD_DIR/* libs/coroutine2 + - python tools/boostdep/depinst/depinst.py coroutine2 + - ./bootstrap.sh + - ./b2 headers + +script: + - |- + echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam + - ./b2 -j 3 libs/coroutine2/test toolset=$TOOLSET cxxstd=$CXXSTD + +notifications: + email: + on_success: always From 0114d19a4636eb594b4b200a7c6ebc9b89d38e47 Mon Sep 17 00:00:00 2001 From: Daniela Engert Date: Mon, 1 Jan 2018 16:42:45 +0100 Subject: [PATCH 8/8] Inheriting std::iterator is deprecated in C++17 Therefore replace inheritance by lifting std::iterator's members into the derived class. Signed-off-by: Daniela Engert --- .../coroutine2/detail/pull_coroutine.hpp | 24 ++++++++++++++----- .../coroutine2/detail/push_coroutine.hpp | 16 +++++++++++-- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/include/boost/coroutine2/detail/pull_coroutine.hpp b/include/boost/coroutine2/detail/pull_coroutine.hpp index 928a477..c8ea49f 100644 --- a/include/boost/coroutine2/detail/pull_coroutine.hpp +++ b/include/boost/coroutine2/detail/pull_coroutine.hpp @@ -68,7 +68,7 @@ public: T get() noexcept; - class iterator : public std::iterator< std::input_iterator_tag, typename std::remove_reference< T >::type > { + class iterator { private: pull_coroutine< T > * c_{ nullptr }; @@ -88,8 +88,14 @@ public: } public: - typedef typename iterator::pointer pointer_t; - typedef typename iterator::reference reference_t; + typedef std::input_iterator_tag iterator_category; + typedef typename std::remove_reference< T >::type value_type; + typedef std::ptrdiff_t difference_type; + typedef value_type * pointer; + typedef value_type & reference; + + typedef pointer pointer_t; + typedef reference reference_t; iterator() noexcept = default; @@ -179,7 +185,7 @@ public: T & get() noexcept; - class iterator : public std::iterator< std::input_iterator_tag, typename std::remove_reference< T >::type > { + class iterator { private: pull_coroutine< T & > * c_{ nullptr }; @@ -199,8 +205,14 @@ public: } public: - typedef typename iterator::pointer pointer_t; - typedef typename iterator::reference reference_t; + typedef std::input_iterator_tag iterator_category; + typedef typename std::remove_reference< T >::type value_type; + typedef std::ptrdiff_t difference_type; + typedef value_type * pointer; + typedef value_type & reference; + + typedef pointer pointer_t; + typedef reference reference_t; iterator() noexcept = default; diff --git a/include/boost/coroutine2/detail/push_coroutine.hpp b/include/boost/coroutine2/detail/push_coroutine.hpp index e68c880..4b5ba5c 100644 --- a/include/boost/coroutine2/detail/push_coroutine.hpp +++ b/include/boost/coroutine2/detail/push_coroutine.hpp @@ -66,11 +66,17 @@ public: bool operator!() const noexcept; - class iterator : public std::iterator< std::output_iterator_tag, void, void, void, void > { + class iterator { private: push_coroutine< T > * c_{ nullptr }; public: + typedef std::output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + iterator() noexcept = default; explicit iterator( push_coroutine< T > * c) noexcept : @@ -143,11 +149,17 @@ public: bool operator!() const noexcept; - class iterator : public std::iterator< std::output_iterator_tag, void, void, void, void > { + class iterator { private: push_coroutine< T & > * c_{ nullptr }; public: + typedef std::output_iterator_tag iterator_category; + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + iterator() noexcept = default; explicit iterator( push_coroutine< T & > * c) noexcept :