/*
Formatting library for C++
Copyright (c) 2012 - present, Victor Zverovich
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--- Optional exception to the license ---
As an exception, if, as a result of your compiling your source code, portions
of this Software are embedded into a machine-executable object form of such
source code, you may redistribute such embedded portions in such object form
without including the above copyright and permission notices.
*/
#ifndef FMT_FORMAT_H_
#define FMT_FORMAT_H_
#include <cmath> // std::signbit
#include <cstdint> // uint32_t
#include <cstring> // std::memcpy
#include <limits> // std::numeric_limits
#include <memory> // std::uninitialized_copy
#include <stdexcept> // std::runtime_error
#include <system_error> // std::system_error
#ifdef __cpp_lib_bit_cast
# include <bit> // std::bitcast
#endif
#include "core.h"
#if FMT_GCC_VERSION
# define FMT_GCC_VISIBILITY_HIDDEN __attribute__((visibility("hidden")))
#else
# define FMT_GCC_VISIBILITY_HIDDEN
#endif
#ifdef __NVCC__
# define FMT_CUDA_VERSION (__CUDACC_VER_MAJOR__ * 100 + __CUDACC_VER_MINOR__)
#else
# define FMT_CUDA_VERSION 0
#endif
#ifdef __has_builtin
# define FMT_HAS_BUILTIN(x) __has_builtin(x)
#else
# define FMT_HAS_BUILTIN(x) 0
#endif
#if FMT_GCC_VERSION || FMT_CLANG_VERSION
# define FMT_NOINLINE __attribute__((noinline))
#else
# define FMT_NOINLINE
#endif
#if FMT_MSC_VERSION
# define FMT_MSC_DEFAULT = default
#else
# define FMT_MSC_DEFAULT
#endif
#ifndef FMT_THROW
# if FMT_EXCEPTIONS
# if FMT_MSC_VERSION || defined(__NVCC__)
FMT_BEGIN_NAMESPACE
namespace detail {
template <typename Exception> inline void do_throw(const Exception& x) {
// Silence unreachable code warnings in MSVC and NVCC because these
// are nearly impossible to fix in a generic code.
volatile bool b = true;
if (b) throw x;
}
} // namespace detail
FMT_END_NAMESPACE
# define FMT_THROW(x) detail::do_throw(x)
# else
# define FMT_THROW(x) throw x
# endif
# else
# define FMT_THROW(x) \
do { \
FMT_ASSERT(false, (x).what()); \
} while (false)
# endif
#endif
#if FMT_EXCEPTIONS
# define FMT_TRY try
# define FMT_CATCH(x) catch (x)
#else
# define FMT_TRY if (true)
# define FMT_CATCH(x) if (false)
#endif
#ifndef FMT_MAYBE_UNUSED
# if FMT_HAS_CPP17_ATTRIBUTE(maybe_unused)
# define FMT_MAYBE_UNUSED [[maybe_unused]]
# else
# define FMT_MAYBE_UNUSED
# endif
#endif
#ifndef FMT_USE_USER_DEFINED_LITERALS
// EDG based compilers (Intel, NVIDIA, Elbrus, etc), GCC and MSVC support UDLs.
# if (FMT_HAS_FEATURE(cxx_user_literals) || FMT_GCC_VERSION >= 407 || \
FMT_MSC_VERSION >= 1900) && \
(!defined(__EDG_VERSION__) || __EDG_VERSION__ >= /* UDL feature */ 480)
# define FMT_USE_USER_DEFINED_LITERALS 1
# else
# define FMT_USE_USER_DEFINED_LITERALS 0
# endif
#endif
// Defining FMT_REDUCE_INT_INSTANTIATIONS to 1, will reduce the number of
// integer formatter template instantiations to just one by only using the
// largest integer type. This results in a reduction in binary size but will
// cause a decrease in integer formatting performance.
#if !defined(FMT_REDUCE_INT_INSTANTIATIONS)
# define FMT_REDUCE_INT_INSTANTIATIONS 0
#endif
// __builtin_clz is broken in clang with Microsoft CodeGen:
// https://github.com/fmtlib/fmt/issues/519.
#if !FMT_MSC_VERSION
# if FMT_HAS_BUILTIN(__builtin_clz) || FMT_GCC_VERSION || FMT_ICC_VERSION
# define FMT_BUILTIN_CLZ(n) __builtin_clz(n)
# endif
# if FMT_HAS_BUILTIN(__builtin_clzll) || FMT_GCC_VERSION || FMT_ICC_VERSION
# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n)
# endif
#endif
// __builtin_ctz is broken in Intel Compiler Classic on Windows:
// https://github.com/fmtlib/fmt/issues/2510.
#ifndef __ICL
# if FMT_HAS_BUILTIN(__builtin_ctz) || FMT_GCC_VERSION || FMT_ICC_VERSION || \
defined(__NVCOMPILER)
# define FMT_BUILTIN_CTZ(n) __builtin_ctz(n)
# endif
# if FMT_HAS_BUILTIN(__builtin_ctzll) || FMT_GCC_VERSION || \
FMT_ICC_VERSION || defined(__NVCOMPILER)
# define FMT_BUILTIN_CTZLL(n) __builtin_ctzll(n)
# endif
#endif
#if FMT_MSC_VERSION
# include <intrin.h> // _BitScanReverse[64], _BitScanForward[64], _umul128
#endif
// Some compilers masquerade as both MSVC and GCC-likes or otherwise support
// __builtin_clz and __builtin_clzll, so only define FMT_BUILTIN_CLZ using the
// MSVC intrinsics if the clz and clzll builtins are not available.
#if FMT_MSC_VERSION && !defined(FMT_BUILTIN_CLZLL) && \
!defined(FMT_BUILTIN_CTZLL)
FMT_BEGIN_NAMESPACE
namespace detail {
// Avoid Clang with Microsoft CodeGen's -Wunknown-pragmas warning.
# if !defined(__clang__)
# pragma intrinsic(_BitScanForward)
# pragma intrinsic(_BitScanReverse)
# if defined(_WIN64)
# pragma intrinsic(_BitScanForward64)
# pragma intrinsic(_BitScanReverse64)
# endif
# endif
inline auto clz(uint32_t x) -> int {
unsigned long r = 0;
_BitScanReverse(&r, x);
FMT_ASSERT(x != 0, "");
// Static analysis complains about using uninitialized data
// "r", but the only way that can happen is if "x" is 0,
// which the callers guarantee to not happen.
FMT_MSC_WARNING(suppress : 6102)
return 31 ^ static_cast<int>(r);
}
# define FMT_BUILTIN_CLZ(n) detail::clz(n)
inline auto clzll(uint64_t x) -> int {
unsigned long r = 0;
# ifdef _WIN64
_BitScanReverse64(&r, x);
# else
// Scan the high 32 bits.
if (_BitScanReverse(&r, static_cast<uint32_t>(x >> 32))) return 63 ^ (r + 32);
// Scan the low 32 bits.
_BitScanReverse(&r, static_cast<uint32_t>(x));
# endif
FMT_ASSERT(x != 0, "");
FMT_MSC_WARNING(suppress : 6102) // Suppress a bogus static analysis warning.
return 63 ^ static_cast<int>(r);
}
# define FMT_BUILTIN_CLZLL(n) detail::clzll(n)
inline auto ctz(uint32_t x) -> int {
unsigned long r = 0;
_BitScanForward(&r, x);
FMT_ASSERT(x != 0, "");
FMT_MSC_WARNING(suppress : 6102) // Suppress a bogus static analysis warning.
return static_cast<int>(r);
}
# define FMT_BUILTIN_CTZ(n) detail::ctz(n)
inline auto ctzll(uint64_t x) -> int {
unsigned long r = 0;
FMT_ASSERT(x != 0, "");
FMT_MSC_WARNING(suppress : 6102) // Suppress a bogus static analysis warning.
# ifdef _WIN64
_BitScanForward64(&r, x);
# else
// Scan the low 32 bits.
if (_BitScanForward(&r, static_cast<uint32_t>(x))) return static_cast<int>(r);
// Scan the high 32 bits.
_BitScanForward(&r, static_cast<uint32_t>(x >> 32));
r += 32;
# endif
return static_cast<int>(r);
}
# define FMT_BUILTIN_CTZLL(n) detail::ctzll(n)
} // namespace detail
FMT_END_NAMESPACE
#endif
FMT_BEGIN_NAMESPACE
namespace detail {
FMT_CONSTEXPR inline void abort_fuzzing_if(bool condition) {
ignore_unused(condition);
#ifdef FMT_FUZZ
if (condition) throw std::runtime_error("fuzzing limit reached");
#endif
}
template <typename CharT, CharT... C>
没有合适的资源?快使用搜索试试~ 我知道了~
spdlog-1.12.0-include
共104个文件
h:103个
rst:1个
需积分: 0 5 下载量 187 浏览量
2023-10-13
10:06:59
上传
评论
收藏 249KB ZIP 举报
温馨提示
spdlog-1.12.0-include
资源推荐
资源详情
资源评论
收起资源包目录
spdlog-1.12.0-include (104个子文件)
format.h 151KB
core.h 109KB
format-inl.h 73KB
chrono.h 66KB
pattern_formatter-inl.h 43KB
color.h 24KB
ranges.h 23KB
compile.h 21KB
printf.h 20KB
os-inl.h 17KB
logger.h 14KB
os.h 14KB
common.h 13KB
spdlog.h 11KB
qt_sinks.h 10KB
xchar.h 9KB
win_eventlog_sink.h 9KB
registry-inl.h 9KB
daily_file_sink.h 8KB
ostream.h 7KB
args.h 7KB
bin_to_hex.h 7KB
logger-inl.h 7KB
hourly_file_sink.h 6KB
tweakme.h 6KB
wincolor_sink-inl.h 6KB
std.h 5KB
file_helper-inl.h 5KB
rotating_file_sink-inl.h 5KB
android_sink.h 5KB
ansicolor_sink-inl.h 5KB
fmt_helper.h 4KB
tcp_client-windows.h 4KB
systemd_sink.h 4KB
mpmc_blocking_q.h 4KB
kafka_sink.h 4KB
stdout_sinks-inl.h 4KB
registry.h 4KB
tcp_client.h 4KB
ansicolor_sink.h 4KB
os.h 4KB
mongo_sink.h 4KB
syslog_sink.h 4KB
pattern_formatter.h 4KB
async.h 4KB
thread_pool-inl.h 3KB
circular_q.h 3KB
thread_pool.h 3KB
helpers-inl.h 3KB
dup_filter_sink.h 3KB
udp_client-windows.h 3KB
spdlog-inl.h 3KB
wincolor_sink.h 3KB
rotating_file_sink.h 3KB
async_logger-inl.h 2KB
dist_sink.h 2KB
stdout_sinks.h 2KB
udp_client.h 2KB
async_logger.h 2KB
tcp_sink.h 2KB
ringbuffer_sink.h 2KB
common-inl.h 2KB
msvc_sink.h 2KB
backtracer-inl.h 2KB
basic_file_sink.h 2KB
udp_sink.h 2KB
base_sink-inl.h 2KB
periodic_worker.h 2KB
file_helper.h 2KB
stopwatch.h 2KB
log_msg_buffer-inl.h 2KB
stdout_color_sinks.h 2KB
callback_sink.h 2KB
base_sink.h 2KB
ostream_sink.h 1KB
argv.h 1KB
null_sink.h 1KB
stdout_color_sinks-inl.h 1KB
backtracer.h 1KB
log_msg.h 1KB
log_msg-inl.h 1KB
basic_file_sink-inl.h 1KB
fmt.h 1004B
env.h 988B
null_mutex.h 967B
log_msg_buffer.h 933B
sink.h 891B
synchronous_factory.h 753B
sink-inl.h 725B
helpers.h 714B
periodic_worker-inl.h 622B
std.h 613B
console_globals.h 609B
compile.h 531B
ostr.h 526B
ranges.h 523B
chrono.h 523B
xchar.h 520B
formatter.h 462B
version.h 331B
共 104 条
- 1
- 2
资源评论
htj10
- 粉丝: 1
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- IMG_5905.PNG
- Cyclone Version 9.51
- 高性能量化回测工具 hikyuu 2.0.3 python 3.12 windows 安装包
- 省级城乡居民基本养老保险情况数据集(2010-2022年).xlsx
- 舞队填写版.cpp
- 基于BP神经网络的多输入单输出回归预测.zip
- 高性能量化回测工具 hikyuu 2.0.3 python 3.9 windows 安装包
- 省级城镇职工基本养老保险情况2000-2022年.xlsx
- 高性能量化回测工具 hikyuu 2.0.3 python 3.10 windows 安装包
- 算法部署-使用OpenVINO+C#部署PaddleOCR字符识别算法-项目源码-优质项目实战.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功