File: constexpr-99287.C

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (61 lines) | stat: -rw-r--r-- 1,916 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// PR c++/99287
// { dg-do compile { target c++20 } }

namespace std {
struct source_location {
  static consteval source_location
  current(const void *__p = __builtin_source_location()) {
    source_location __ret;
    __ret._M_impl = static_cast<const __impl *>(__p);
    return __ret;
  }
  constexpr const char *function_name() {
    return _M_impl ? _M_impl->_M_function_name : "";
  }
  struct __impl {
    const char *_M_file_name;
    const char *_M_function_name;
    unsigned _M_line;
    unsigned _M_column;
  } const *_M_impl;
};
struct char_traits {
  static constexpr long length(const char *__s) {
    return __builtin_strlen(__s);
  }
};
template <typename _CharT, typename _Traits = char_traits>
class basic_string_view {
public:
  using traits_type = _Traits;
  using size_type = unsigned long;
  constexpr basic_string_view(const _CharT *__str)
      : _M_len{traits_type::length(__str)}, _M_str{__str} {}
  constexpr size_type find(const _CharT *, size_type, size_type) const noexcept;
  constexpr size_type find(_CharT *__str) {
    long __trans_tmp_1 = traits_type::length(__str);
    return find(__str, 0, __trans_tmp_1);
  }
  long _M_len;
  const _CharT *_M_str;
};
using string_view = basic_string_view<const char>;
template <typename _CharT, typename _Traits>
constexpr unsigned long
basic_string_view<_CharT, _Traits>::find(const _CharT *__str, size_type,
                                         size_type __n) const noexcept {
  int __trans_tmp_2;
  const _CharT *__first = _M_str;
  size_type __len = _M_len;
  while (__len >= __n) {
    __trans_tmp_2 = __builtin_memcmp(__first, __str, __n);
    if (__trans_tmp_2 == 0)
      return __first - _M_str;
    __len = _M_str - ++__first;
  }
}
} // namespace std
template <typename> consteval auto f() {
  return std::string_view{std::source_location::current().function_name()};
}
int main() { constexpr auto s = f<int>().find("int"); }