source: Daodan/MSYS2/mingw32/include/c++/11.2.0/source_location@ 1181

Last change on this file since 1181 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 2.6 KB
RevLine 
[1166]1// <source_location> -*- C++ -*-
2
3// Copyright (C) 2020-2021 Free Software Foundation, Inc.
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
19
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
24
25/** @file include/source_location
26 * This is a Standard C++ Library header.
27 */
28
29#ifndef _GLIBCXX_SRCLOC
30#define _GLIBCXX_SRCLOC 1
31
32#if __cplusplus > 201703L && __has_builtin(__builtin_source_location)
33#include <bits/c++config.h>
34
35namespace std
36{
37_GLIBCXX_BEGIN_NAMESPACE_VERSION
38
39#define __cpp_lib_source_location 201907L
40
41 /// A class that describes a location in source code.
42 struct source_location
43 {
44 private:
45 using uint_least32_t = __UINT_LEAST32_TYPE__;
46
47 public:
48
49 // [support.srcloc.cons], creation
50 static consteval source_location
51 current(const void* __p = __builtin_source_location()) noexcept
52 {
53 source_location __ret;
54 __ret._M_impl = static_cast <const __impl*>(__p);
55 return __ret;
56 }
57
58 constexpr source_location() noexcept { }
59
60 // [support.srcloc.obs], observers
61 constexpr uint_least32_t
62 line() const noexcept
63 { return _M_impl ? _M_impl->_M_line : 0u; }
64
65 constexpr uint_least32_t
66 column() const noexcept
67 { return _M_impl ? _M_impl->_M_column : 0u; }
68
69 constexpr const char*
70 file_name() const noexcept
71 { return _M_impl ? _M_impl->_M_file_name : ""; }
72
73 constexpr const char*
74 function_name() const noexcept
75 { return _M_impl ? _M_impl->_M_function_name : ""; }
76
77 private:
78 struct __impl
79 {
80 const char* _M_file_name;
81 const char* _M_function_name;
82 unsigned _M_line;
83 unsigned _M_column;
84 };
85
86 const __impl* _M_impl = nullptr;
87 };
88
89_GLIBCXX_END_NAMESPACE_VERSION
90} // namespace std
91#endif // C++20 && __builtin_source_location
92#endif // _GLIBCXX_SRCLOC
Note: See TracBrowser for help on using the repository browser.