Skip to content

Conversation

RPeschke
Copy link

Summary

Add a new port ntuples: a header-only C++20 library for named-field tuples and lightweight dataframe-style helpers.

What this port does

  • Installs public headers from core/include/ to include/.
  • Provides a relocatable CMake config at share/ntuples/ntuples-config.cmake that defines the target ntuples::ntuples.
  • Enforces C++20 via target_compile_features(… cxx_std_20).
  • Adds a share/ntuples/usage file so users see clear usage instructions after install.

CMake usage

find_package(ntuples CONFIG REQUIRED)
target_link_libraries(<your-target> PRIVATE ntuples::ntuples)

Example Use

  nt_new_field_name(index);
  nt_new_field_name(index_squared);
  
  int main(){

  for (auto &&e : std::views::iota(1, 10) 
                            | std::views::transform([](auto i) { 
                                 return nt::ntuple(
                                               index = i, 
                                               index_squared = i * i, 
                                               nt_field(cubed) = i * i * i
                                            ); 
                            }) 
                            | std::views::filter([](auto &&t) {
                                return t.cubed >= 216; 
                            }
                               ))
  {

  
        std::cout << e.index  << "   "; 
        std::cout << e.index_squared.v << "   "; 
        std::cout << e.cubed << "   ";  
        std::cout << e << std::endl;            
    }
  }
index: 6   36   cubed: 216   | index: 6 | index_squared: 36 | cubed: 216 |
index: 7   49   cubed: 343   | index: 7 | index_squared: 49 | cubed: 343 |
index: 8   64   cubed: 512   | index: 8 | index_squared: 64 | cubed: 512 |
index: 9   81   cubed: 729   | index: 9 | index_squared: 81 | cubed: 729 |

This is just a header-only C++20 library. It uses ordinary C++ (templates, operator overloading, a few macros). No new language, no code generation, no external reflection.

  • Named fields at compile time.
    nt_new_field_name(index); nt_new_field_name(index_squared); declares tag types used as field names.

  • Create records on the fly.
    nt::ntuple(index = i, index_squared = i * i, nt_field(cubed) = i * i * i) constructs a lightweight record.
    Known fields use the tags above; nt_field(cubed) shows an ad-hoc field defined inline.

  • Composes with range pipelines.
    Ideal for using with range library.

  • Ergonomic access.
    Access fields by name (t.cubed) or by index (nt::get<0>(t)), with compile-time type checking.

@RPeschke
Copy link
Author

@microsoft-github-policy-service agree

BillyONeal
BillyONeal previously approved these changes Aug 15, 2025
Copy link
Member

@BillyONeal BillyONeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed fixes for the comments.

add_library(ntuples INTERFACE)
add_library(ntuples::ntuples ALIAS ntuples)
target_include_directories(ntuples INTERFACE \"\${_IMPORT_PREFIX}/include\")
target_compile_features(ntuples INTERFACE cxx_std_20)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
target_compile_features(ntuples INTERFACE cxx_std_20)
target_compile_features(ntuples INTERFACE cxx_std_17)

https://github.com/RPeschke/ntuples/blob/e3b124f148678fa3cfa2780579948a62df7da23e/CMakeLists.txt#L28

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

I am sorry but it will not compile with c++17

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry but it will not compile with c++17

I see, in that case upstream should be fixed so that we aren't randomly doing something different than upstream. (Doesn't mean upstream needs to change before we would merge this, just that we would want upstream's approval before doing something different)

I made the original comment and pushed the change without realizing that you were also the upstream maintainer 😅. You should probably fix that and remove the attempt to set CMAKE_CXX_STANDARD.

@BillyONeal BillyONeal self-requested a review August 15, 2025 19:11
@BillyONeal
Copy link
Member

I got so distracted by header-only that I forgot to check the name :(

repology doesn't suggest this name is already used for that repo and trying to google the name in the context of C or C++ seems to point everywhere to GSL ( https://www.gnu.org/software/gsl/doc/html/ntuple.html ) or to std::tuple.

Would you accept changing the name of the port to rpeschke-ntuples?

@BillyONeal BillyONeal added the requires:vcpkg-team-review This PR or issue requires someone on the vcpkg team to take a further look. label Aug 15, 2025
@BillyONeal
Copy link
Member

Tagging vcpkg-team-review for the name. On balance I think the name is probably fine because I think there's little chance of actual confusion but ntuples doesn't meet the automatic OK standard under https://learn.microsoft.com/vcpkg/contributing/maintainer-guide#check-names-against-other-repositories

@RPeschke
Copy link
Author

OK thanks. Let me see how how i can change the name. Does the Entire library need a new name or only the port (the name inside vcpkg)

@BillyONeal
Copy link
Member

Just the name inside vcpkg. I can push that change for you if you're OK with it.

@RPeschke
Copy link
Author

maybe we can called it something like named_tuple that would be short and descriptive however we can also go for rp-ntuples

@BillyONeal
Copy link
Member

maybe we can called it something like named_tuple that would be short and descriptive however we can also go for rp-ntuples

I still need to ask for approval from another maintainer for those. Decision tree is something like:

  1. If already has that name on repology -> Approve! , otherwise:
  2. If clearly comes up as top result with no conflicts on Google/Bing/etc. -> Approve! , otherwise:
  3. If follows 'githubowner-githubrepo' convention -> Approve! , otherwise:
  4. More than one vcpkg maintainer needs to OK it.

Thanks for the new port; will keep you posted.

the library requires cxx_std_20 to compile
@RPeschke
Copy link
Author

Hi,

I don't understand the 2 failing checks. Can you help me with that?

Thanks,

@BillyONeal
Copy link
Member

I don't understand the 2 failing checks. Can you help me with that?

The version database needs fixed because the port has changed. I would normally just push a fix for that but I haven't bothered while I'm waiting for another name approval.

Comment on lines 8 to 9
"vcpkg-cmake",
"vcpkg-cmake-config"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be host dependencies.

Comment on lines 22 to 23
vcpkg_install_copyright(FILE_LIST
"${SOURCE_PATH}/LICENSE" "${SOURCE_PATH}/LICENSE.txt"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
vcpkg_install_copyright(FILE_LIST
"${SOURCE_PATH}/LICENSE" "${SOURCE_PATH}/LICENSE.txt"
vcpkg_install_copyright(FILE_LIST
"${SOURCE_PATH}/LICENSE"

We don't need 2 copies of the same file :)

@BillyONeal BillyONeal added the category:new-port The issue is requesting a new library to be added; consider making a PR! label Aug 20, 2025
@BillyONeal
Copy link
Member

@ras0219-msft @vicroms and I discussed today.

We can't merge ntuples or named-tuples. We would be happy with rp-ntuples.

We can merge this without changing the "real library name" or where the headers are installed, but adding a prefix or some other distinguishing name is likely to help you and your users because it will make you easy to Google. (It seems unlikely that the search conflicts with GSL ntuples and/or std::tuple would be resolved soon :) )

@BillyONeal BillyONeal removed the requires:vcpkg-team-review This PR or issue requires someone on the vcpkg team to take a further look. label Aug 21, 2025
@RPeschke
Copy link
Author

OK I think rp-ntuples is fine. Thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:new-port The issue is requesting a new library to be added; consider making a PR!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants