Home / News+Media / News / Krystian's Q2 2024 Update

Krystian's Q2 2024 Update

Tooling Posted on July 15, 2024

MrDocs

This quarter, my primary focus was on MrDocs. To that end, I’m happy to say that the P0 milestone for MrDocs has been reached! Although the vast majority of the work I did was bug hunting/fixing, I also implemented a novel feature which detects and simplifies types that use the SFINAE idiom.

Prior to C++20, the primary mechanism for constraining templates was through use of the SFINAE idiom, e.g.:

cpp
template<typename T>
std::enable_if_t<std::is_pointer_v<T>, T> f(T); // only viable when T is a pointer type

These kinds of constrained declarations can be rather “noisy” due to the constraints being written into the type of the declaration. One solution is to use macros to show the simplified type when generating documentation:

cpp
template<typename T>
#ifndef DOCS
std::enable_if_t<std::is_pointer_v<T>, T>
#else
T
#endif
f(T);

but this requires manual intervention on the part of the library author. Since MrDocs generates documentation using the clang AST, we can detect whether a template implements the SFINAE idiom and show the “replacement type” instead:

cpp
template<typename T>
std::enable_if_t<std::is_pointer_v<T>, T> // rendered as 'T' in the documentation since std::enable_if_t is a SFINAE template
f(T);

In general, MrDocs determines whether a type naming a member M of a class template C uses the SFINAE idiom by identifying every declaration of M in the primary template and every partial/explicit specialization of C. If M is not found in at least one of the class definitions, and if every declaration of M declares it as an alias for the same type as every other declaration, then C is a template implementing the SFINAE.

Clang

In addition to working on MrDocs, I merged a number of clang patches this quarter:

Related news

View all →
Tooling

MrDocs Bootstrap: One Script to Build Them All

When new developers joined the MrDocs team, we expected the usual ramp-up: learning the codebase, understanding the architecture, and getting comfortable with the review process. What we did not expect was that building and testing the project would be the hardest part.

Read more →

Stay up to date

Get Alliance news, project updates, and community highlights in your inbox.

Subscribe

Empowering C++ by funding libraries, building community, and advancing the language.

Connect with us