// Matrix Construct // // Copyright (C) Matrix Construct Developers, Authors & Contributors // Copyright (C) 2016-2018 Jason Volk // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice is present in all copies. The // full license for this software is available in the LICENSE file. #pragma once #define HAVE_IRCD_UTIL_ITERATOR_H namespace ircd { inline namespace util { // // To collapse pairs of iterators down to a single type // template struct iterpair :std::pair { using std::pair::pair; }; template T & begin(iterpair &i) { return std::get<0>(i); } template T & end(iterpair &i) { return std::get<1>(i); } template const T & begin(const iterpair &i) { return std::get<0>(i); } template const T & end(const iterpair &i) { return std::get<1>(i); } // // To collapse pairs of iterators down to a single type // typed by an object with iterator typedefs. // template using iterators = std::pair; template using const_iterators = std::pair; template typename T::iterator begin(const iterators &i) { return i.first; } template typename T::iterator end(const iterators &i) { return i.second; } template typename T::const_iterator begin(const const_iterators &ci) { return ci.first; } template typename T::const_iterator end(const const_iterators &ci) { return ci.second; } } // namespace util } // namespace ircd