1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_SPECIALIZED_ALGORITHMS_H
10#define _LIBCPP___ALGORITHM_SPECIALIZED_ALGORITHMS_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18_LIBCPP_BEGIN_NAMESPACE_STD
19
20namespace _Algorithm {
21struct __copy {};
22struct __fill_n {};
23struct __for_each {};
24} // namespace _Algorithm
25
26template <class>
27struct __single_iterator;
28
29template <class, class>
30struct __iterator_pair;
31
32template <class>
33struct __single_range;
34
35// This struct allows specializing algorithms for specific arguments. This is useful when we know a more efficient
36// algorithm implementation for e.g. library-defined iterators. _Alg is one of tags defined inside the _Algorithm
37// namespace above. _Ranges is an essentially arbitrary subset of the arguments to the algorithm that are used for
38// dispatching. This set is specific to the algorithm: look at each algorithm to see which arguments they use for
39// dispatching to specialized algorithms.
40//
41// A specialization of `__specialized_algorithm` has to define `__has_algorithm` to true for the specialized algorithm
42// to be used. This is intended for cases where iterators can do generic unwrapping and forward to a different
43// specialization of `__specialized_algorithm`.
44//
45// If __has_algorithm is true, there has to be an operator() which will get called with the actual arguments to the
46// algorithm.
47template <class _Alg, class... _Ranges>
48struct __specialized_algorithm {
49 static const bool __has_algorithm = false;
50};
51
52_LIBCPP_END_NAMESPACE_STD
53
54#endif // _LIBCPP___ALGORITHM_SPECIALIZED_ALGORITHMS_H