1 // <experimental/source_location> -*- C++ -*-
3 // Copyright (C) 2015 Free Software Foundation, Inc.
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)
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.
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.
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/>.
25 /** @file experimental/source_location
26 * This is a TS C++ Library header.
29 #ifndef _GLIBCXX_EXPERIMENTAL_SRCLOC
30 #define _GLIBCXX_EXPERIMENTAL_SRCLOC 1
35 _GLIBCXX_BEGIN_NAMESPACE_VERSION
37 namespace experimental {
38 inline namespace fundamentals_v2 {
39 #define __cpp_lib_experimental_source_location 201505
41 struct source_location
43 #ifndef _GLIBCXX_USE_C99_STDINT_TR1
45 using uint_least32_t = unsigned;
49 // 14.1.2, source_location creation
50 static constexpr source_location
51 current(const char* __file = __builtin_FILE(),
52 const char* __func = __builtin_FUNCTION(),
53 int __line = __builtin_LINE(),
54 int __col = 0) noexcept
56 source_location __loc;
57 __loc._M_file = __file;
58 __loc._M_func = __func;
59 __loc._M_line = __line;
64 constexpr source_location() noexcept
65 : _M_file("unknown"), _M_func(_M_file), _M_line(0), _M_col(0)
68 // 14.1.3, source_location field access
69 constexpr uint_least32_t line() const noexcept { return _M_line; }
70 constexpr uint_least32_t column() const noexcept { return _M_col; }
71 constexpr const char* file_name() const noexcept { return _M_file; }
72 constexpr const char* function_name() const noexcept { return _M_func; }
77 uint_least32_t _M_line;
78 uint_least32_t _M_col;
80 } // namespace fundamentals_v2
81 } // namespace experimental
83 _GLIBCXX_END_NAMESPACE_VERSION