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 diff --git a/include/boost/coroutine2/detail/pull_coroutine.hpp b/include/boost/coroutine2/detail/pull_coroutine.hpp index 32cd68e..c8ea49f 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; } @@ -69,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 }; @@ -89,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; @@ -168,8 +173,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; } @@ -181,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 }; @@ -201,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; @@ -278,8 +288,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/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.hpp b/include/boost/coroutine2/detail/push_coroutine.hpp index d152be2..4b5ba5c 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; } @@ -67,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 : @@ -134,8 +139,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; } @@ -145,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 : @@ -212,8 +222,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; } 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