has_one_element.hpp 818 B

1234567891011121314151617181920212223242526272829
  1. // Boost.Geometry
  2. // Copyright (c) 2014-2021, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  4. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  5. // Licensed under the Boost Software License version 1.0.
  6. // http://www.boost.org/users/license.html
  7. #ifndef BOOST_GEOMETRY_ITERATORS_DETAIL_HAS_ONE_ELEMENT_HPP
  8. #define BOOST_GEOMETRY_ITERATORS_DETAIL_HAS_ONE_ELEMENT_HPP
  9. namespace boost { namespace geometry { namespace detail
  10. {
  11. // free function to test if an iterator range has a single element
  12. template <typename Iterator>
  13. inline bool has_one_element(Iterator first, Iterator last)
  14. {
  15. return first != last && ++first == last;
  16. }
  17. }}} // namespace boost::geometry::detail
  18. #endif // BOOST_GEOMETRY_ITERATORS_DETAIL_HAS_ONE_ELEMENT_HPP