Búzios Trip Report
I wrote up a short report from the Búzios meeting and where things stand with C++26:
https://cppalliance.org/newsmedia/news/b%C3%BAzios-trip-report-what-the-c26-ballot-taught-us/
https://redd.it/1y4jsui
@r_cpp
I wrote up a short report from the Búzios meeting and where things stand with C++26:
https://cppalliance.org/newsmedia/news/b%C3%BAzios-trip-report-what-the-c26-ballot-taught-us/
https://redd.it/1y4jsui
@r_cpp
C++ Alliance
Búzios Trip Report: What the C++26 ballot taught us
Ladybird's first alpha release
https://simonwillison.net/2026/Nov/23/ladybird
https://redd.it/1y55520
@r_cpp
https://simonwillison.net/2026/Nov/23/ladybird
https://redd.it/1y55520
@r_cpp
Simon Willison’s Weblog
Ladybird’s first alpha release
Ladybird is an astonishingly ambitious project: a new browser, in 2026, with its own implementation of most of the key components—HTML parsing, CSS engine, layout, JavaScript, even WebAssembly. It still …
How do you debug certificate trust differences between Windows and OpenSSL?
I'm interested in understanding how ***C++ developers*** handle **TLS** certificate verification issues on Windows.
One situation I'm particularly curious about is when the same server certificate is accepted by Windows but rejected by **OpenSSL**, or vice versa.
For example:
* **Windows CryptoAPI** builds a trusted certificate chain, but **OpenSSL** fails verification.
* The certificate exists in the Windows certificate store, but **OpenSSL** doesn't appear to use the same trust source.
* The verification result differs depending on the certificate store, CA bundle, or verification settings.
For developers who have encountered this:
1. How do you usually investigate the difference?
2. Do you use **Windows CryptoAPI** tools, **OpenSSL** commands, ***custom C++ code***, or a combination?
3. Is it easy to identify the exact reason for the disagreement, or does it require a lot of manual debugging?
4. Have you found any existing tool that makes this process straightforward?
I'm particularly interested in real-world experiences from people maintaining **C++ applications** on Windows.
I'd appreciate hearing how you currently approach this problem.
https://redd.it/1y5en1j
@r_cpp
I'm interested in understanding how ***C++ developers*** handle **TLS** certificate verification issues on Windows.
One situation I'm particularly curious about is when the same server certificate is accepted by Windows but rejected by **OpenSSL**, or vice versa.
For example:
* **Windows CryptoAPI** builds a trusted certificate chain, but **OpenSSL** fails verification.
* The certificate exists in the Windows certificate store, but **OpenSSL** doesn't appear to use the same trust source.
* The verification result differs depending on the certificate store, CA bundle, or verification settings.
For developers who have encountered this:
1. How do you usually investigate the difference?
2. Do you use **Windows CryptoAPI** tools, **OpenSSL** commands, ***custom C++ code***, or a combination?
3. Is it easy to identify the exact reason for the disagreement, or does it require a lot of manual debugging?
4. Have you found any existing tool that makes this process straightforward?
I'm particularly interested in real-world experiences from people maintaining **C++ applications** on Windows.
I'd appreciate hearing how you currently approach this problem.
https://redd.it/1y5en1j
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
toml++ 3.5.1 released
Hiya folks,
I've finally come back to maintaining toml++ after a couple of years focusing on other things, and am happy to share that v3.5.1 is now [released](https://github.com/marzer/tomlplusplus/releases/tag/v3.5.1)! Highlights from v3.4.0:
* Support for TOML v1.1.0 🎉️
* Support for C++20 `std::chrono` date-time types
* Support for C++20 modules with `import tomlplusplus`
* Faster parsing (\~2x, \~5x for string-heavy docs)
* Faster formatting (\~1.5x, \~3x for float-heavy docs)
* Faster compiles and smaller binaries for some configurations
* Lots of fixes for various issues
Full changelog [here.](https://github.com/marzer/tomlplusplus/blob/v3.5.1/CHANGELOG.md)
>*"What about v3.5.0?"*
3.5.0 and 3.5.1 are exactly the same library. The patch bump was necessary because I'm rusty and messed up the tagging for v3.5.0, so I just made a new release right on top of it to keep things safe for packaging systems.
Also this will probably the last feature bump for the v3.x series of releases. There's a whole load of larger structural and design things I want to get to that require breaking changes, so I'll start cooking on those and hopefully have that out as a v4 next year some time. Until then it'll just be patch bumps.
https://redd.it/1y5j956
@r_cpp
Hiya folks,
I've finally come back to maintaining toml++ after a couple of years focusing on other things, and am happy to share that v3.5.1 is now [released](https://github.com/marzer/tomlplusplus/releases/tag/v3.5.1)! Highlights from v3.4.0:
* Support for TOML v1.1.0 🎉️
* Support for C++20 `std::chrono` date-time types
* Support for C++20 modules with `import tomlplusplus`
* Faster parsing (\~2x, \~5x for string-heavy docs)
* Faster formatting (\~1.5x, \~3x for float-heavy docs)
* Faster compiles and smaller binaries for some configurations
* Lots of fixes for various issues
Full changelog [here.](https://github.com/marzer/tomlplusplus/blob/v3.5.1/CHANGELOG.md)
>*"What about v3.5.0?"*
3.5.0 and 3.5.1 are exactly the same library. The patch bump was necessary because I'm rusty and messed up the tagging for v3.5.0, so I just made a new release right on top of it to keep things safe for packaging systems.
Also this will probably the last feature bump for the v3.x series of releases. There's a whole load of larger structural and design things I want to get to that require breaking changes, so I'll start cooking on those and hopefully have that out as a v4 next year some time. Until then it'll just be patch bumps.
https://redd.it/1y5j956
@r_cpp
GitHub
Release v3.5.1 · marzer/tomlplusplus
This release was triggered automatically by a merge to master.See CHANGELOG.md for a human-friendly change log. 🎉
Full Changelog: v3.5.0...v3.5.1
Full Changelog: v3.5.0...v3.5.1
GridLock: an open-source debugger built for MPI and parallel C++ development
https://github.com/bnorthern42/GridLock
https://redd.it/1y5otym
@r_cpp
https://github.com/bnorthern42/GridLock
https://redd.it/1y5otym
@r_cpp
GitHub
GitHub - bnorthern42/GridLock: GridLock is an experimental, high-performance MPI graphical debugger frontend for x86_64 Linux.…
GridLock is an experimental, high-performance MPI graphical debugger frontend for x86_64 Linux. Built native on Wayland using Qt6 and largely generated via AI-driven development (vibe-coding), it p...
Clang -fmodules-driver: C++20 modules and import std without an external build system
Earlier this year, Clang added basic support for building simple programs that use Clang modules or C++20 modules directly from the Clang driver, without an external build system. This includes using the
The documentation landed yesterday (although the feature is already in Clang 23), so I thought I would advertise it here now: https://clang.llvm.org/docs/StandardCPlusPlusModules.html#compiling-modules-using-the-clang-modules-driver
This is still a very experimental feature, and it doesn't support caching yet. Currently, all modules used are recompiled on each invocation, which is especially painful with the large C++ Standard library modules.
The main purpose of this isn't to compete with dedicated build systems such as CMake, but to make modules more accessible. I hope this makes it easier to use modules in smaller examples, and maybe even in some people's first Hello World programs.
(This was part of a GSoC project I did in 2025. Happy to answer any questions!)
https://redd.it/1y61f6j
@r_cpp
Earlier this year, Clang added basic support for building simple programs that use Clang modules or C++20 modules directly from the Clang driver, without an external build system. This includes using the
std/std.compat modules: https://godbolt.org/z/sahYMsxnaThe documentation landed yesterday (although the feature is already in Clang 23), so I thought I would advertise it here now: https://clang.llvm.org/docs/StandardCPlusPlusModules.html#compiling-modules-using-the-clang-modules-driver
This is still a very experimental feature, and it doesn't support caching yet. Currently, all modules used are recompiled on each invocation, which is especially painful with the large C++ Standard library modules.
The main purpose of this isn't to compete with dedicated build systems such as CMake, but to make modules more accessible. I hope this makes it easier to use modules in smaller examples, and maybe even in some people's first Hello World programs.
(This was part of a GSoC project I did in 2025. Happy to answer any questions!)
https://redd.it/1y61f6j
@r_cpp
godbolt.org
Compiler Explorer - C++
import std;
auto main() -> int {
std::println("Hello, World!");
}
auto main() -> int {
std::println("Hello, World!");
}
Am I the only one that hates C++'s STD library?
I've been using C++ for a couple years and I can't stand the standard library anymore. To me it's a mess of headers and classes. It's jammed with repeating features but in different formats, such as
Also, would it be crazy to write my own, simpler, version of the STD library for my own projects?
https://redd.it/1y75392
@r_cpp
I've been using C++ for a couple years and I can't stand the standard library anymore. To me it's a mess of headers and classes. It's jammed with repeating features but in different formats, such as
std::print, modules, and other stuff from C that are just in the C++ format. Don't get me started on strings, I've encountered at least 10 different ways of handling strings in different libraries and it's a hastle to convert between each of them. Am I the only one that hates it? If so please correct me and tell me on how to properly love it.Also, would it be crazy to write my own, simpler, version of the STD library for my own projects?
https://redd.it/1y75392
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
Anyone want to improve c++ together?
I am thinking of creating a small group for people who want to improve their c++ skills. Anyone interested,?
https://redd.it/1y7gkxs
@r_cpp
I am thinking of creating a small group for people who want to improve their c++ skills. Anyone interested,?
https://redd.it/1y7gkxs
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
Who cares about the new C++ standard?
https://a4z.noexcept.dev/blog/2026/11/28/who-cares-about-the-new-cpp-standard.html
https://redd.it/1y7j4mb
@r_cpp
https://a4z.noexcept.dev/blog/2026/11/28/who-cares-about-the-new-cpp-standard.html
https://redd.it/1y7j4mb
@r_cpp
a4z.noexcept.dev
Who cares about the new C++ standard?
A new C++ standard gets plenty of attention. But who is waiting for it, and what would make an upgrade worth the effort?
new language made from scratch, then used to build a compiler that turns go code into c++
virex is a tiny language and vm i built in c++17. it has a bytecode compiler, a jit, 103 stdlib modules written in virex itself, an lsp, editor grammars, and a playground that turns go code into c++17. the playground runs in the browser and uses the real compiler when served locally. no external deps. code and docs: https://github.com/q2hp0/virex ·
https://q2hp0.github.io/virex/
https://redd.it/1y7rp5c
@r_cpp
virex is a tiny language and vm i built in c++17. it has a bytecode compiler, a jit, 103 stdlib modules written in virex itself, an lsp, editor grammars, and a playground that turns go code into c++17. the playground runs in the browser and uses the real compiler when served locally. no external deps. code and docs: https://github.com/q2hp0/virex ·
https://q2hp0.github.io/virex/
https://redd.it/1y7rp5c
@r_cpp
GitHub
GitHub - q2hp0/virex: a new language made from scratch, then used to build a compiler that turns go code into c++
a new language made from scratch, then used to build a compiler that turns go code into c++ - q2hp0/virex
RFC: Using external modules or CPS with Visual Studio
Seeking feedback on this suggestion I'll hopefully make to devcom. I barely know what I'm doing, so I probably missed something. Do things work the way I think they do...
## Visual Studio/MSBuild should have a way to easily consume modules and/or CPS from external libraries
What is the intended way to consume the modules of an external library? I'm not sure. With header-based libs, you just add to the include and lib paths, and away you go. Maybe stick that stuff in a props file. But for external modules? Are you supposed to reference a pre-built IFC directly?
Instead, external module sources could be discovered and built as needed by the project system. So, external modules would retain the familiar user experience of headers. You just point the project at module sources and it should Just Work.
It would also mean that the library's CMake script would not need a separate compilation of modules to a static library or IFC. A binary distribution probably shouldn't contain an IFC anyway as they may be so much more compiler-dependent than ABI.
Method 1
Add a "additional module source directories" project setting. The build system will lookup all cppm/ixx files in that directory to satisfy imports.
Method 2
Go all-in on the Common Package Specification. Add a "CPS files" project setting. The build system will collect and maybe cache information from listed CPS files to resolve includes and imports, and add additional compile settings. CPS files may use https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3286r0.pdf to list modules.
And the build system can automatically link the libraries listed in those CPS files. Maybe only if a header or module from them is used.
The advantage of this method is that it's a single setting for a library. You'd only need to list the CPS in project settings, and nothing else. The CPS provides the include paths, the libs, preprocessor defs, and module sources.
Method 3
Dedicated external CPS project type. Like method 2, but the project would make available the listed CPS packages, their includes, libs, modules, and preprocessor defs, to referencing projects through the project reference system. Such a project would also act as a central place to put the compiled modules rather than possibly duplicating them among referencing projects.
---
Or some other method. In essence, external modules should be easy to use, and CPS files should be the future, as maybe exported by CMake. So the project system should handle that stuff in some way.
Also, the project reference system should try to reuse compiled modules if possible, just like with
https://redd.it/1y7rjct
@r_cpp
Seeking feedback on this suggestion I'll hopefully make to devcom. I barely know what I'm doing, so I probably missed something. Do things work the way I think they do...
## Visual Studio/MSBuild should have a way to easily consume modules and/or CPS from external libraries
What is the intended way to consume the modules of an external library? I'm not sure. With header-based libs, you just add to the include and lib paths, and away you go. Maybe stick that stuff in a props file. But for external modules? Are you supposed to reference a pre-built IFC directly?
Instead, external module sources could be discovered and built as needed by the project system. So, external modules would retain the familiar user experience of headers. You just point the project at module sources and it should Just Work.
It would also mean that the library's CMake script would not need a separate compilation of modules to a static library or IFC. A binary distribution probably shouldn't contain an IFC anyway as they may be so much more compiler-dependent than ABI.
Method 1
Add a "additional module source directories" project setting. The build system will lookup all cppm/ixx files in that directory to satisfy imports.
Method 2
Go all-in on the Common Package Specification. Add a "CPS files" project setting. The build system will collect and maybe cache information from listed CPS files to resolve includes and imports, and add additional compile settings. CPS files may use https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3286r0.pdf to list modules.
And the build system can automatically link the libraries listed in those CPS files. Maybe only if a header or module from them is used.
The advantage of this method is that it's a single setting for a library. You'd only need to list the CPS in project settings, and nothing else. The CPS provides the include paths, the libs, preprocessor defs, and module sources.
Method 3
Dedicated external CPS project type. Like method 2, but the project would make available the listed CPS packages, their includes, libs, modules, and preprocessor defs, to referencing projects through the project reference system. Such a project would also act as a central place to put the compiled modules rather than possibly duplicating them among referencing projects.
---
Or some other method. In essence, external modules should be easy to use, and CPS files should be the future, as maybe exported by CMake. So the project system should handle that stuff in some way.
Also, the project reference system should try to reuse compiled modules if possible, just like with
import std.https://redd.it/1y7rjct
@r_cpp
What do you think about modules?
I see lot of people don't like modules how they are now can they can be improved and what can be suitable solution what do you think?
https://redd.it/1y7rrbs
@r_cpp
I see lot of people don't like modules how they are now can they can be improved and what can be suitable solution what do you think?
https://redd.it/1y7rrbs
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
Coroutines in your own standard library?
I don't use the C++ standard library. I have my own. I was thinking about trying co_(await,yield,return) keyword and looking at the generated assembly. Has anyone done this before? Or try to use it without using the standard C++ lib? I see `__builtin_coro_*` but haven't really looked into this much
https://redd.it/1y82xoc
@r_cpp
I don't use the C++ standard library. I have my own. I was thinking about trying co_(await,yield,return) keyword and looking at the generated assembly. Has anyone done this before? Or try to use it without using the standard C++ lib? I see `__builtin_coro_*` but haven't really looked into this much
https://redd.it/1y82xoc
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
What do you guys use to manage C++ dependencies?
I’m thinking about making a simple package manager for C++, something like npm or Golang style.
The idea is to just type “add fmt” and let it handle dependencies, version conflicts and CMake stuff.
I know about Conan and vcpkg, but I wonder if something simpler would be useful.
What do you guys think?
https://redd.it/1y8ccds
@r_cpp
I’m thinking about making a simple package manager for C++, something like npm or Golang style.
The idea is to just type “add fmt” and let it handle dependencies, version conflicts and CMake stuff.
I know about Conan and vcpkg, but I wonder if something simpler would be useful.
What do you guys think?
https://redd.it/1y8ccds
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
How much variance in benchmarks are normal?
I am currently making some changes to an existing sorting function and I have to benchmark the results in order to merge them. The problem is that, running the same benchmark with the same inputs, with the same number of iterations, yields up to 15% variance on median time on different seperate runs. I am using Google's Benchmark framework, pin the task, disable CPU scaling, disable ASLR, and the variance is still like this. Is this normal for a micro-benchmark? If it is, then it is near impossible to pin-point improvements unless they are huge.
https://redd.it/1y8quvp
@r_cpp
I am currently making some changes to an existing sorting function and I have to benchmark the results in order to merge them. The problem is that, running the same benchmark with the same inputs, with the same number of iterations, yields up to 15% variance on median time on different seperate runs. I am using Google's Benchmark framework, pin the task, disable CPU scaling, disable ASLR, and the variance is still like this. Is this normal for a micro-benchmark? If it is, then it is near impossible to pin-point improvements unless they are huge.
https://redd.it/1y8quvp
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
Notes on the discrete Fourier transform (DFT)
https://eli.thegreenplace.net/2026/notes-on-the-discrete-fourier-transform-dft
https://redd.it/1y8sri6
@r_cpp
https://eli.thegreenplace.net/2026/notes-on-the-discrete-fourier-transform-dft
https://redd.it/1y8sri6
@r_cpp
What are all different industries C++ developers works mostly? And changing industry in C++ niche is possible?
https://redd.it/1y90a7g
@r_cpp
https://redd.it/1y90a7g
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
Specific features you look for in a logger
For the past months I've been developing a c++20 async logging library similar in architecture to Quill or fmtlog. It started out just as a small project mostly for learning more about multithreading and lock-free algorithms, but then it grew to be pretty competitive in feature set and performance, so I decided to try and release it.
It's not ready yet but it's getting there. Performance wise it either beats or matches Quill in frontend latency depending on the cpu, and backend throughput is consistently about twice as high partly thanks to c++20 consteval. Feature wise it is much slimmer than Quill obviously, but that could be an advantage for compile times and general ease of use and configuration (I've focused a lot on making configuration easy).
Now to my question: Outside of the standard feature set like levels, level filtering, rolling file sinks, etc, do you look for any specific features in a logging library? Maybe some specific sink type, structured logging to a niche format, more advanced runtime log filtering (for example filtering on file, named log statement groups, or even individual statements), or something else that comes to mind.
I realise logging is a very mature field and that most things can be done in the popular libraries, but if there's still a feature you want but don't see very often I'd love to know.
https://redd.it/1y92r8y
@r_cpp
For the past months I've been developing a c++20 async logging library similar in architecture to Quill or fmtlog. It started out just as a small project mostly for learning more about multithreading and lock-free algorithms, but then it grew to be pretty competitive in feature set and performance, so I decided to try and release it.
It's not ready yet but it's getting there. Performance wise it either beats or matches Quill in frontend latency depending on the cpu, and backend throughput is consistently about twice as high partly thanks to c++20 consteval. Feature wise it is much slimmer than Quill obviously, but that could be an advantage for compile times and general ease of use and configuration (I've focused a lot on making configuration easy).
Now to my question: Outside of the standard feature set like levels, level filtering, rolling file sinks, etc, do you look for any specific features in a logging library? Maybe some specific sink type, structured logging to a niche format, more advanced runtime log filtering (for example filtering on file, named log statement groups, or even individual statements), or something else that comes to mind.
I realise logging is a very mature field and that most things can be done in the popular libraries, but if there's still a feature you want but don't see very often I'd love to know.
https://redd.it/1y92r8y
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
제가만든c++로만든ln이빠를까요 c++의내장함수ln이더빠를까요
x = 1917
custom\_ln (직접 구현한 커스텀 함수) : 7.5585167430456446,0.0000000000000000)
std::log(c++내장함수) : (7.5585167430456446,0.0000000000000000)
절대 오차 : 0.0000000000000000e+00
custom\_ln\_minimax\_nodiv : 113.983 ms
std::log : 119.788 ms
sink : 1511703348.185087
만약코드가궁금하다면
#include <iostream>
#include <cmath>
#include <bit>
#include <chrono>
#include <array>
#include <iomanip>
#include <limits>
struct LutEntry {
double inv_m;
double ln_m;
};
constexpr std::array<LutEntry, 64> make_ln_lut() noexcept {
std::array<LutEntry, 64> lut{};
for (int k = 0; k < 64; ++k) {
double m = 1.0 + (static_cast<double>(k) + 0.5) / 64.0;
double inv = 1.0 / m;
double u = (m - 1.0) / (m + 1.0);
double w = u * u;
double term = u;
double sum = 0.0;
for (int n = 1; n <= 25; n += 2) {
sum += term / static_cast<double>(n);
term *= w;
}
lut[k] = { inv, 2.0 * sum };
}
return lut;
}
inline constexpr auto LN_LUT = make_ln_lut();
inline double custom_ln_minimax_nodiv(double x) noexcept {
constexpr double LN2 = 0.693147180559945309417232121458;
uint64_t bits = std::bit_cast<uint64_t>(x);
int64_t B = static_cast<int64_t>((bits >> 52) & 0x7FF) - 1023;
uint64_t mantissa_bits = (bits & 0x000FFFFFFFFFFFFFULL) | 0x3FF0000000000000ULL;
double A = std::bit_cast<double>(mantissa_bits);
uint64_t idx = (bits >> 46) & 0x3FULL;
const auto& entry = LN_LUT[idx];
double t = A * entry.inv_m - 1.0;
double t2 = t * t;
constexpr double c1 = 1.00000000000000000;
constexpr double c2 = 0.50000000000000000;
constexpr double c3 = 0.33333333333333333;
constexpr double c4 = 0.25000000000000000;
constexpr double c5 = 0.20000000000000000;
constexpr double c6 = 0.16666666666666666;
constexpr double c7 = 0.14285714285714285;
double odd = c1 + t2 * (c3 + t2 * (c5 + t2 * c7));
double even = c2 + t2 * (c4 + t2 * c6);
double ln_1p_t = t * (odd - t * even);
return static_cast<double>(B) * LN2 + entry.ln_m + ln_1p_t;
}
int main() {
constexpr int ITERATIONS = 100'000'000;
volatile double sink = 0.0;
std::cout << "양수 x를 입력하세요 (종료하려면 q 또는 Ctrl+D):\n";
double x = 0.0;
while (true) {
std::cout << "\nx = ";
if (!(std::cin >> x)) {
if (std::cin.eof()) break;
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cout << "숫자만 입력해 주세요.\n";
continue;
}
if (x <= 0.0) {
std::cout << "양수(> 0)를 입력해 주세요.\n";
continue;
}
double acc1 = 0.0;
auto t0 = std::chrono::high_resolution_clock::now();
for (int i = 0; i < ITERATIONS; ++i) {
acc1 += custom_ln_minimax_nodiv(x);
}
auto t1 = std::chrono::high_resolution_clock::now();
double acc2 = 0.0;
auto t2 = std::chrono::high_resolution_clock::now();
for (int i = 0; i < ITERATIONS; ++i) {
acc2 += std::log(x);
}
auto t3 = std::chrono::high_resolution_clock::now();
sink = acc1 + acc2;
std::chrono::duration<double, std::milli> custom_ms = t1 - t0;
std::chrono::duration<double, std::milli> std_ms = t3 - t2;
std::cout << std::fixed << std::setprecision(3);
std::cout << "custom_ln_minimax_nodiv : " << custom_ms.count() << " ms\n";
x = 1917
custom\_ln (직접 구현한 커스텀 함수) : 7.5585167430456446,0.0000000000000000)
std::log(c++내장함수) : (7.5585167430456446,0.0000000000000000)
절대 오차 : 0.0000000000000000e+00
custom\_ln\_minimax\_nodiv : 113.983 ms
std::log : 119.788 ms
sink : 1511703348.185087
만약코드가궁금하다면
#include <iostream>
#include <cmath>
#include <bit>
#include <chrono>
#include <array>
#include <iomanip>
#include <limits>
struct LutEntry {
double inv_m;
double ln_m;
};
constexpr std::array<LutEntry, 64> make_ln_lut() noexcept {
std::array<LutEntry, 64> lut{};
for (int k = 0; k < 64; ++k) {
double m = 1.0 + (static_cast<double>(k) + 0.5) / 64.0;
double inv = 1.0 / m;
double u = (m - 1.0) / (m + 1.0);
double w = u * u;
double term = u;
double sum = 0.0;
for (int n = 1; n <= 25; n += 2) {
sum += term / static_cast<double>(n);
term *= w;
}
lut[k] = { inv, 2.0 * sum };
}
return lut;
}
inline constexpr auto LN_LUT = make_ln_lut();
inline double custom_ln_minimax_nodiv(double x) noexcept {
constexpr double LN2 = 0.693147180559945309417232121458;
uint64_t bits = std::bit_cast<uint64_t>(x);
int64_t B = static_cast<int64_t>((bits >> 52) & 0x7FF) - 1023;
uint64_t mantissa_bits = (bits & 0x000FFFFFFFFFFFFFULL) | 0x3FF0000000000000ULL;
double A = std::bit_cast<double>(mantissa_bits);
uint64_t idx = (bits >> 46) & 0x3FULL;
const auto& entry = LN_LUT[idx];
double t = A * entry.inv_m - 1.0;
double t2 = t * t;
constexpr double c1 = 1.00000000000000000;
constexpr double c2 = 0.50000000000000000;
constexpr double c3 = 0.33333333333333333;
constexpr double c4 = 0.25000000000000000;
constexpr double c5 = 0.20000000000000000;
constexpr double c6 = 0.16666666666666666;
constexpr double c7 = 0.14285714285714285;
double odd = c1 + t2 * (c3 + t2 * (c5 + t2 * c7));
double even = c2 + t2 * (c4 + t2 * c6);
double ln_1p_t = t * (odd - t * even);
return static_cast<double>(B) * LN2 + entry.ln_m + ln_1p_t;
}
int main() {
constexpr int ITERATIONS = 100'000'000;
volatile double sink = 0.0;
std::cout << "양수 x를 입력하세요 (종료하려면 q 또는 Ctrl+D):\n";
double x = 0.0;
while (true) {
std::cout << "\nx = ";
if (!(std::cin >> x)) {
if (std::cin.eof()) break;
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cout << "숫자만 입력해 주세요.\n";
continue;
}
if (x <= 0.0) {
std::cout << "양수(> 0)를 입력해 주세요.\n";
continue;
}
double acc1 = 0.0;
auto t0 = std::chrono::high_resolution_clock::now();
for (int i = 0; i < ITERATIONS; ++i) {
acc1 += custom_ln_minimax_nodiv(x);
}
auto t1 = std::chrono::high_resolution_clock::now();
double acc2 = 0.0;
auto t2 = std::chrono::high_resolution_clock::now();
for (int i = 0; i < ITERATIONS; ++i) {
acc2 += std::log(x);
}
auto t3 = std::chrono::high_resolution_clock::now();
sink = acc1 + acc2;
std::chrono::duration<double, std::milli> custom_ms = t1 - t0;
std::chrono::duration<double, std::milli> std_ms = t3 - t2;
std::cout << std::fixed << std::setprecision(3);
std::cout << "custom_ln_minimax_nodiv : " << custom_ms.count() << " ms\n";
std::cout << "std::log : " << std_ms.count() << " ms\n";
std::cout << std::setprecision(6);
std::cout << "sink : " << sink << "\n";
}
return 0;
}입니다
https://redd.it/1y94k6o
@r_cpp
std::cout << std::setprecision(6);
std::cout << "sink : " << sink << "\n";
}
return 0;
}입니다
https://redd.it/1y94k6o
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community