// Copyright (c) 2012 // Utrecht University (The Netherlands), // ETH Zurich (Switzerland), // INRIA Sophia-Antipolis (France), // Max-Planck-Institute Saarbruecken (Germany), // and Tel-Aviv University (Israel). All rights reserved. // // This file is part of CGAL (www.cgal.org) // // $URL: https://github.com/CGAL/cgal/blob/v5.2/Circulator/include/CGAL/Circulator/Circulator_concepts.h $ // $Id: Circulator_concepts.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Philipp Möller #ifndef CGAL_CIRCULATOR_CONCEPTS_H #define CGAL_CIRCULATOR_CONCEPTS_H #include #include #include #include #include namespace CGAL { namespace Concepts { template void deref(T& t) { t.operator->(); } template void deref(T*) { // valid anyway } // N.B.: there is no such concept as Circulator as it is immaterial template struct ForwardCirculator : boost::Assignable, boost::DefaultConstructible , boost::CopyConstructible { // for some odd reason circulators have no associated traits typedef typename C::value_type value_type; typedef typename C::reference reference; typedef typename C::pointer pointer; typedef typename C::difference_type difference_type; // odd name but useful for compatibility typedef typename C::iterator_category iterator_category; // this requirement ought to be a mistake because it breaks // compatibility with iterators // typedef typename C::size_type size_type; BOOST_CONCEPT_USAGE(ForwardCirculator) { // CGAL_UNUSED is needed with g++ 4.8, otherwise it warns: // "typedef ‘boost_concept_check68’ locally defined but not used // [-Wunused-local-typedefs]" BOOST_CONCEPT_ASSERT((boost::SignedInteger)) CGAL_UNUSED; BOOST_CONCEPT_ASSERT((boost::Convertible)) CGAL_UNUSED; boost::require_boolean_expr(a == nullptr); boost::require_boolean_expr(a != nullptr); ++a; a++; (void)*a; // suppress unused warning, don't check the return type // to allow for proxies deref(a); } private: C a; }; template struct BidirectionalCirculator : ForwardCirculator { BOOST_CONCEPT_USAGE(BidirectionalCirculator) { BOOST_CONCEPT_ASSERT((boost::Convertible)) CGAL_UNUSED; --a; a--; } private: C a; }; template struct RandomAccessCirculator : BidirectionalCirculator { BOOST_CONCEPT_USAGE(RandomAccessCirculator) { BOOST_CONCEPT_ASSERT((boost::Convertible)) CGAL_UNUSED; c += n; // addition c = c + n; c = n + c; c -= n; // subtraction c = c - n; n = c - b; // difference (void)c[n]; // operator[] c.min_circulator(); // minimum } private: C c, b; C i; typename C::difference_type n; }; } // Concept } // CGAL #include #endif /* CGAL_CIRCULATOR_CONCEPTS_H */