• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2024 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CORE_FXCRT_TEMPLATE_UTIL_H_
6 #define CORE_FXCRT_TEMPLATE_UTIL_H_
7 
8 #include <stddef.h>
9 #include <iosfwd>
10 #include <iterator>
11 #include <type_traits>
12 #include <utility>
13 
14 #include "build/build_config.h"
15 
16 namespace pdfium {
17 
18 template <class T> struct is_non_const_reference : std::false_type {};
19 template <class T> struct is_non_const_reference<T&> : std::true_type {};
20 template <class T> struct is_non_const_reference<const T&> : std::false_type {};
21 
22 namespace internal {
23 
24 // Uses expression SFINAE to detect whether using operator<< would work.
25 template <typename T, typename = void>
26 struct SupportsOstreamOperator : std::false_type {};
27 template <typename T>
28 struct SupportsOstreamOperator<T,
29                                decltype(void(std::declval<std::ostream&>()
30                                              << std::declval<T>()))>
31     : std::true_type {};
32 
33 // Used to detech whether the given type is an iterator.  This is normally used
34 // with std::enable_if to provide disambiguation for functions that take
35 // templatzed iterators as input.
36 template <typename T, typename = void>
37 struct is_iterator : std::false_type {};
38 
39 template <typename T>
40 struct is_iterator<
41     T,
42     std::void_t<typename std::iterator_traits<T>::iterator_category>>
43     : std::true_type {};
44 
45 }  // namespace internal
46 
47 }  // namespace pdfium
48 
49 #endif  // CORE_FXCRT_TEMPLATE_UTIL_H_
50