From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 55392 invoked by alias); 13 Nov 2015 12:56:54 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 55333 invoked by uid 89); 13 Nov 2015 12:56:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 13 Nov 2015 12:56:52 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id DCEFC8E220; Fri, 13 Nov 2015 12:56:50 +0000 (UTC) Received: from localhost (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tADCuniS006250; Fri, 13 Nov 2015 07:56:50 -0500 Date: Fri, 13 Nov 2015 12:56:00 -0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [patch] Implement std::experimental::source_location (sort of) Message-ID: <20151113125649.GO2937@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="IjNIXuzrMEaOuFwn" Content-Disposition: inline X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.5.24 (2015-08-30) X-SW-Source: 2015-11/txt/msg01687.txt.bz2 --IjNIXuzrMEaOuFwn Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-length: 404 This is a non-conforming implementation of https://rawgit.com/cplusplus/fundamentals-ts/v2/fundamentals-ts.html#reflection.src_loc It doesn't provide any column numbers, and fails to meet the requirement that using current() in a NSDMI will refer to the location of the constructor ... but maybe it's good enough until we get the necessary front-end support. It is experimental, after all. Thoughts? --IjNIXuzrMEaOuFwn Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=source_location Content-length: 2513 // -*- C++ -*- // Copyright (C) 2015 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . /** @file experimental/source_location * This is a TS C++ Library header. */ #ifndef _GLIBCXX_EXPERIMENTAL_SRCLOC #define _GLIBCXX_EXPERIMENTAL_SRCLOC 1 #include namespace std { namespace experimental { inline namespace fundamentals_v2 { _GLIBCXX_BEGIN_NAMESPACE_VERSION struct source_location { // 14.1.2, source_location creation static constexpr source_location current(const char* __file = __builtin_FILE(), const char* __func = __builtin_FUNCTION(), int __line = __builtin_LINE(), int __col = 0) noexcept { source_location __loc; __loc._M_file = __file; __loc._M_func = __func; __loc._M_line = __line; __loc._M_col = __col; return __loc; } constexpr source_location() noexcept : _M_file("unknown"), _M_func(_M_file), _M_line(0), _M_col(0) { } // 14.1.3, source_location field access constexpr uint_least32_t line() const noexcept { return _M_line; } constexpr uint_least32_t column() const noexcept { return _M_col; } constexpr const char* file_name() const noexcept { return _M_file; } constexpr const char* function_name() const noexcept { return _M_func; } private: const char* _M_file; const char* _M_func; uint_least32_t _M_line; uint_least32_t _M_col; }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace fundamentals_v2 } // namespace experimental } // namespace std #endif --IjNIXuzrMEaOuFwn--