Include a `nameof<>()` utility

Open
#112 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
tooling

Research direction

Start by reviewing the requested nameof() behavior in the issue and the referenced Apache Arrow commit, since no cpp11 file or test is identified here. Define the supported type-name output and verify that the implementation avoids RTTI and runtime demangling, then add coverage demonstrating the r_string example and other intended generic error-message uses.

Written by the indexing model from the issue text.

Description

feature

It's possible to implement a nameof<T>() which provides a string representation of T without requiring RTTI or demangling at runtime.

assert(nameof<r_string>() == "cpp11::r_string");

This might be helpful in a number of cases including providing better error messages from generics.

For in-the-wild use, see:
https://github.com/apache/arrow/pull/8246/commits/87c26f7a7e5a393681057923a790f6448ea07817#diff-db94c392857c3bad4f5f69e86cde917bR164-R165

Dominant language
C++
Stars
224
Forks
52
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from r-lib/cpp11

All issues in r-lib/cpp11

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.