Hi Ken, On Mon, Feb 27, 2023 at 5:02 PM Ken Matsui via Gcc <gcc@gcc.gnu.org> wrote: > > Hi, > > My name is Ken Matsui. I am highly interested in contributing to the > project idea, "C++: Implement compiler built-in traits for the > standard library traits." To understand how to implement those traits, > could you please give me some example implementations of the compiler > built-in traits, as well as some recommended traits to get started > with making small patches?
Awesome, thanks for your interest in this project, and welcome! Most of the existing built-in traits are tabulated in gcc/cp/cp-trait.def, and their logic is defined in finish_trait_type or finish_trait_expr in gcc/cp/semantics.cc[2], and then the traits are conditionally used in the standard type trait definitions in libstdc++, e.g. std::remove_cv[3]. Take a look at the following commits that define (and add tests for) the built-in traits __remove_cv, __remove_reference and __remove_cvref and subsequently use them in libstdc++. Note that this first commit predates the new gcc/cp/cp-trait.def file which streamlined much of the boilerplate of adding a new built-in trait. In the new approach (that you would be using), only the semantics.cc change (which defines their logic) would be needed, alongside additions to cp-trait.def to declare each trait. https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=9ca147154074a0de548138b4e73477e94903a855 https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=6ddbbbffbb5759a6c1d56c191364a6bd021f733e To get started, I'd recommend implementing bulit-in traits for std::remove_pointer, std::add_pointer and std::is_reference[4]. Let me know if you have any questions :) [1]: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/cp/cp-trait.def [2]: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/cp/semantics.cc;h=79b7cc72f212cef780a3eea65af2b883bb4ec3c8;hb=HEAD#l12102 [3]: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/include/std/type_traits;h=2bd607a8b8ff52aba6fd205ab1af2bc4b92f78d0;hb=HEAD#l1539 [4]: As specified in https://en.cppreference.com/w/cpp/header/type_traits > > Also, I would appreciate receiving the contact information for the > project mentor, Patrick Palka. > > Sincerely, > Ken Matsui