diff options
Diffstat (limited to 'boost/poly_collection')
-rw-r--r-- | boost/poly_collection/algorithm.hpp | 21 | ||||
-rw-r--r-- | boost/poly_collection/detail/functional.hpp | 7 | ||||
-rw-r--r-- | boost/poly_collection/detail/is_equality_comparable.hpp | 60 | ||||
-rw-r--r-- | boost/poly_collection/detail/is_likely_stateless_lambda.hpp | 70 | ||||
-rw-r--r-- | boost/poly_collection/detail/stride_iterator.hpp | 7 | ||||
-rw-r--r-- | boost/poly_collection/detail/workaround_dr1467.hpp | 35 |
6 files changed, 10 insertions, 190 deletions
diff --git a/boost/poly_collection/algorithm.hpp b/boost/poly_collection/algorithm.hpp index 862e85aa6b..ccf678eb58 100644 --- a/boost/poly_collection/algorithm.hpp +++ b/boost/poly_collection/algorithm.hpp @@ -1,4 +1,4 @@ -/* Copyright 2016-2017 Joaquin M Lopez Munoz. +/* Copyright 2016-2018 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) @@ -19,7 +19,6 @@ #include <boost/poly_collection/detail/iterator_traits.hpp> #include <boost/poly_collection/detail/segment_split.hpp> #include <boost/poly_collection/detail/type_restitution.hpp> -#include <boost/poly_collection/detail/workaround_dr1467.hpp> #include <iterator> #include <type_traits> #include <utility> @@ -91,8 +90,6 @@ bool none_of(const Iterator& first,const Iterator& last,Predicate pred) struct for_each_alg { - BOOST_POLY_COLLECTION_WORKAROUND_DR1467(for_each_alg) - template<typename InputIterator,typename Function> void operator()( InputIterator first,InputIterator last,Function& f)const /* note the & */ @@ -197,8 +194,6 @@ Iterator find_first_of( template<typename... Ts> struct adjacent_find_alg { - BOOST_POLY_COLLECTION_WORKAROUND_DR1467(adjacent_find_alg) - template< typename LocalIterator,typename BinaryPredicate,typename LocalBaseIterator > @@ -289,8 +284,6 @@ std::ptrdiff_t count_if( struct mismatch_alg { - BOOST_POLY_COLLECTION_WORKAROUND_DR1467(mismatch_alg) - template< typename InputIterator1, typename InputIterator2,typename BinaryPredicate @@ -374,8 +367,6 @@ std::pair<Iterator,InputIterator> mismatch( struct equal_alg { - BOOST_POLY_COLLECTION_WORKAROUND_DR1467(equal_alg) - template< typename InputIterator1, typename InputIterator2,typename BinaryPredicate @@ -603,8 +594,6 @@ Iterator find_end( struct search_n_alg { - BOOST_POLY_COLLECTION_WORKAROUND_DR1467(search_n_alg) - template< typename ForwardIterator,typename Size, typename T,typename BinaryPredicate @@ -764,8 +753,6 @@ OutputIterator transform( struct transform2_alg { - BOOST_POLY_COLLECTION_WORKAROUND_DR1467(transform2_alg) - template< typename InputIterator1,typename InputIterator2, typename OutputIterator,typename BinaryOperation @@ -799,8 +786,6 @@ struct replace_copy_alg * conditional operator". */ - BOOST_POLY_COLLECTION_WORKAROUND_DR1467(replace_copy_alg) - template<typename InputIterator,typename OutputIterator,typename T> OutputIterator operator()( InputIterator first,InputIterator last,OutputIterator res, @@ -832,8 +817,6 @@ struct replace_copy_if_alg * conditional operator". */ - BOOST_POLY_COLLECTION_WORKAROUND_DR1467(replace_copy_if_alg) - template< typename InputIterator,typename OutputIterator, typename Predicate,typename T @@ -890,8 +873,6 @@ OutputIterator remove_copy_if( template<typename... Ts> struct unique_copy_alg { - BOOST_POLY_COLLECTION_WORKAROUND_DR1467(unique_copy_alg) - template< typename LocalIterator,typename OutputIterator, typename BinaryPredicate,typename LocalBaseIterator diff --git a/boost/poly_collection/detail/functional.hpp b/boost/poly_collection/detail/functional.hpp index 2d1f8944b8..9fcf05c2ee 100644 --- a/boost/poly_collection/detail/functional.hpp +++ b/boost/poly_collection/detail/functional.hpp @@ -1,4 +1,4 @@ -/* Copyright 2016-2017 Joaquin M Lopez Munoz. +/* Copyright 2016-2018 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) @@ -16,7 +16,6 @@ #include <boost/config.hpp> #include <boost/detail/workaround.hpp> #include <boost/poly_collection/detail/integer_sequence.hpp> -#include <boost/poly_collection/detail/workaround_dr1467.hpp> #include <tuple> #include <utility> @@ -40,8 +39,6 @@ struct name \ #define BOOST_POLY_COLLECTION_DEFINE_OVERLOAD_SET(name,f) \ struct name \ { \ - BOOST_POLY_COLLECTION_WORKAROUND_DR1467(name) \ - \ template<typename... Args> \ auto operator()(Args&&... args)const-> \ decltype(f(std::forward<Args>(args)...)) \ @@ -184,8 +181,6 @@ deref_1st_to_class<F> deref_1st_to(const F& f) struct transparent_equal_to { - BOOST_POLY_COLLECTION_WORKAROUND_DR1467(transparent_equal_to) - template<typename T,typename U> auto operator()(T&& x,U&& y)const noexcept(noexcept(std::forward<T>(x)==std::forward<U>(y))) diff --git a/boost/poly_collection/detail/is_equality_comparable.hpp b/boost/poly_collection/detail/is_equality_comparable.hpp index 898dd55f14..d4d6183854 100644 --- a/boost/poly_collection/detail/is_equality_comparable.hpp +++ b/boost/poly_collection/detail/is_equality_comparable.hpp @@ -1,4 +1,4 @@ -/* Copyright 2017 Joaquin M Lopez Munoz. +/* Copyright 2017-2018 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) @@ -13,15 +13,8 @@ #pragma once #endif -#include <boost/config.hpp> -#include <type_traits> - -#if !defined(BOOST_NO_SFINAE_EXPR) -#include <utility> -#else -#include <boost/poly_collection/detail/is_likely_stateless_lambda.hpp> #include <boost/type_traits/has_equal_to.hpp> -#endif +#include <type_traits> namespace boost{ @@ -29,56 +22,11 @@ namespace poly_collection{ namespace detail{ -#if !defined(BOOST_NO_SFINAE_EXPR) - -/* trivial, expression SFINAE-based implementation */ - -template<typename T,typename=void> -struct is_equality_comparable:std::false_type{}; - template<typename T> -struct is_equality_comparable< - T, - typename std::enable_if< - std::is_convertible< - decltype(std::declval<T>()==std::declval<T>()),bool - >::value - >::type ->:std::true_type{}; - -#else -/* boost::has_equal_to does a decent job without using expression SFINAE, - * but it produces a compile error when the type T being checked is - * convertible to an equality-comparable type Q. Exotic as it may seem, - * this is exactly the situation with the very important case of stateless - * lambda expressions, which are convertible to an equality-comparable - * function pointer with the same signature. We take explicit care of - * stateless lambdas then. - */ - -template<typename T,typename=void> -struct is_equality_comparable:std::integral_constant< +using is_equality_comparable=std::integral_constant< bool, has_equal_to<T,T,bool>::value ->{}; - -template<typename T> -struct is_equality_comparable< - T, - typename std::enable_if<is_likely_stateless_lambda<T>::value>::type ->: -#if !defined(BOOST_MSVC) - std::true_type{}; -#else - /* To complicate things further, in VS stateless lambdas are convertible not - * only to regular function pointers, but also to other call conventions - * such as __stdcall, __fastcall, etc., which makes equality comparison - * ambiguous. - */ - - std::false_type{}; -#endif -#endif +>; } /* namespace poly_collection::detail */ diff --git a/boost/poly_collection/detail/is_likely_stateless_lambda.hpp b/boost/poly_collection/detail/is_likely_stateless_lambda.hpp deleted file mode 100644 index d8469c0dd3..0000000000 --- a/boost/poly_collection/detail/is_likely_stateless_lambda.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright 2017 Joaquin M Lopez Munoz. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or copy at - * http://www.boost.org/LICENSE_1_0.txt) - * - * See http://www.boost.org/libs/poly_collection for library home page. - */ - -#ifndef BOOST_POLY_COLLECTION_DETAIL_IS_LIKELY_STATELESS_LAMBDA_HPP -#define BOOST_POLY_COLLECTION_DETAIL_IS_LIKELY_STATELESS_LAMBDA_HPP - -#if defined(_MSC_VER) -#pragma once -#endif - -#include <type_traits> - -namespace boost{ - -namespace poly_collection{ - -namespace detail{ - -/* Stateless lambda expressions have one (and only one) call operator and are - * convertible to a function pointer with the same signature. Non-lambda types - * could satisfy this too, hence the "likely" qualifier. - */ - -template<typename T> -struct has_one_operator_call_helper -{ - template<typename Q> static std::true_type test(decltype(&Q::operator())*); - template<typename> static std::false_type test(...); - - using type=decltype(test<T>(nullptr)); -}; - -template<typename T> -using has_one_operator_call=typename has_one_operator_call_helper<T>::type; - -template<typename T> -struct equivalent_function_pointer -{ - template<typename Q,typename R,typename... Args> - static auto helper(R (Q::*)(Args...)const)->R(*)(Args...); - template<typename Q,typename R,typename... Args> - static auto helper(R (Q::*)(Args...))->R(*)(Args...); - - using type=decltype(helper(&T::operator())); -}; - -template<typename T,typename=void> -struct is_likely_stateless_lambda:std::false_type{}; - -template<typename T> -struct is_likely_stateless_lambda< - T, - typename std::enable_if<has_one_operator_call<T>::value>::type ->:std::is_convertible< - T, - typename equivalent_function_pointer<T>::type ->{}; - -} /* namespace poly_collection::detail */ - -} /* namespace poly_collection */ - -} /* namespace boost */ - -#endif diff --git a/boost/poly_collection/detail/stride_iterator.hpp b/boost/poly_collection/detail/stride_iterator.hpp index 7312e66675..66ecdf07a0 100644 --- a/boost/poly_collection/detail/stride_iterator.hpp +++ b/boost/poly_collection/detail/stride_iterator.hpp @@ -1,4 +1,4 @@ -/* Copyright 2016 Joaquin M Lopez Munoz. +/* Copyright 2016-2017 Joaquin M Lopez Munoz. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) @@ -106,9 +106,10 @@ private: void increment()noexcept{p=value_ptr(char_ptr(p)+stride_);} void decrement()noexcept{p=value_ptr(char_ptr(p)-stride_);} template<typename Integral> - void advance(Integral n)noexcept{p=value_ptr(char_ptr(p)+n*stride_);} + void advance(Integral n)noexcept + {p=value_ptr(char_ptr(p)+n*(std::ptrdiff_t)stride_);} std::ptrdiff_t distance_to(const stride_iterator& x)const noexcept - {return (char_ptr(x.p)-char_ptr(p))/stride_;} + {return (char_ptr(x.p)-char_ptr(p))/(std::ptrdiff_t)stride_;} Value* p; std::size_t stride_; diff --git a/boost/poly_collection/detail/workaround_dr1467.hpp b/boost/poly_collection/detail/workaround_dr1467.hpp deleted file mode 100644 index 229ec54272..0000000000 --- a/boost/poly_collection/detail/workaround_dr1467.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2017 Joaquin M Lopez Munoz. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or copy at - * http://www.boost.org/LICENSE_1_0.txt) - * - * See http://www.boost.org/libs/poly_collection for library home page. - */ - -#ifndef BOOST_POLY_COLLECTION_DETAIL_WORKAROUND_DR1467_HPP -#define BOOST_POLY_COLLECTION_DETAIL_WORKAROUND_DR1467_HPP - -#if defined(_MSC_VER) -#pragma once -#endif - -#include <boost/config.hpp> -#include <boost/detail/workaround.hpp> - -#if BOOST_WORKAROUND(BOOST_GCC_VERSION,<50000)||\ - defined(BOOST_CLANG)&&\ - (__clang_major__<3||(__clang_major__==3&&__clang_minor__<=6)) -/* Defect report 1467 denounces that for aggregate types an intended {}-style - * copy construction will be mistaken for aggregate initialization: - * http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1467 - * - * A solution is to define a default constructor for the offending class so - * that it is no longer an aggregate. - */ - -#define BOOST_POLY_COLLECTION_WORKAROUND_DR1467(name) name(){} -#else -#define BOOST_POLY_COLLECTION_WORKAROUND_DR1467(name) -#endif - -#endif |