xtd
1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
xtd.core
include
xtd
internal
__xtd_source_location.hpp
Go to the documentation of this file.
1
3
#pragma once
5
#define __XTD_STD_INTERNAL__
6
#include "
__xtd_std_version.hpp
"
7
#undef __XTD_STD_INTERNAL__
8
9
#if defined(__xtd__cpp_lib_source_location)
10
#include <source_location>
11
using
__xtd_source_location__ = std::source_location;
12
#else
13
// Fallback implementation for std::source_location for compatibility reasons.
14
//
15
// Although std::source_location is part of C++20 and supported in recent compiler versions,
16
// the support on Apple platforms (Xcode/Clang) is still incomplete or inconsistent,
17
// especially on versions prior to Xcode 15.4.
18
//
19
// This fallback uses compiler builtins (__builtin_FILE, __builtin_LINE, etc.) to
20
// provide similar functionality without relying on std::source_location.
21
//
22
// We keep this fallback to ensure compatibility with older toolchains and to avoid
23
// breaking CI or user builds when newer Xcode versions are not available.
24
//
25
// Once support for std::source_location becomes reliable across all supported
26
// Xcode versions, this fallback can be removed.
27
//
28
// See: https://developer.apple.com/forums/thread/713513 for related discussion.
29
//
30
#include <cstdint>
31
#include <memory>
32
33
class
__xtd_source_location__ {
34
public
:
35
const
char
* file_name() const noexcept {
return
data_->file;}
36
std::uint32_t line() const noexcept {
return
data_->line;}
37
const
char
* function_name() const noexcept {
return
data_->func;}
38
std::uint32_t column() const noexcept {
return
data_->column;}
39
40
[[nodicard]]
static
auto
current
(
const
char
* file = __builtin_FILE(), std::uint32_t line = __builtin_LINE(),
const
char
* func = __builtin_FUNCTION(), std::uint32_t column = __builtin_COLUMN()) noexcept -> __xtd_source_location__ {
41
auto
csl = __xtd_source_location__ {};
42
*csl.data_ = {file, line,
func
, column};
43
return
csl;
44
}
45
46
private
:
47
struct
data
{
48
const
char
* file;
49
std::uint32_t line;
50
const
char
*
func
;
51
std::uint32_t column;
52
};
53
std::shared_ptr<data> data_ = std::make_shared<data>();
54
};
55
#endif
__xtd_std_version.hpp
xtd::func
xtd::delegate< result_t(arguments_t... arguments)> func
Represents a delegate that has variables parameters and returns a value of the type specified by the ...
Definition
func.hpp:27
xtd::io::seek_origin::current
@ current
Specifies the current position within a stream.
Definition
seek_origin.hpp:20
xtd::data
constexpr auto data() const noexcept -> const_pointer
Gets direct access to the underlying contiguous storage.
Definition
read_only_span.hpp:197
Generated on
for xtd by
Gammasoft
. All rights reserved.