has_one_element.hpp 736 B

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