René's URL Explorer Experiment


Title: Support for Exporting Template and Namespaced Functions in Rcpp · Issue #1368 · RcppCore/Rcpp · GitHub

Open Graph Title: Support for Exporting Template and Namespaced Functions in Rcpp · Issue #1368 · RcppCore/Rcpp

X Title: Support for Exporting Template and Namespaced Functions in Rcpp · Issue #1368 · RcppCore/Rcpp

Description: Enhancement: Support for Exporting Template and Namespaced Functions in Rcpp Rcpp has been an incredible tool for bridging R and C++, and its flexibility has inspired me to explore new ways to extend its functionality. Building on the ex...

Open Graph Description: Enhancement: Support for Exporting Template and Namespaced Functions in Rcpp Rcpp has been an incredible tool for bridging R and C++, and its flexibility has inspired me to explore new ways to exte...

X Description: Enhancement: Support for Exporting Template and Namespaced Functions in Rcpp Rcpp has been an incredible tool for bridging R and C++, and its flexibility has inspired me to explore new ways to exte...

Opengraph URL: https://github.com/RcppCore/Rcpp/issues/1368

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support for Exporting Template and Namespaced Functions in Rcpp","articleBody":"## Enhancement: Support for Exporting Template and Namespaced Functions in Rcpp\n\nRcpp has been an incredible tool for bridging R and C++, and its flexibility has inspired me to explore new ways to extend its functionality. Building on the existing framework, I have added support for **exporting template functions** and functions inside **namespaces**, expanding the possibilities for advanced C++ integration.\n\n### Key Features\n\n#### 1. Support for Exporting Template Functions\n- The `Rcpp::export` attribute can now be applied to **explicit template instantiations**.\n- The function must have an explicit instantiation in the `.cpp` file for it to be correctly recognized.\n- Works seamlessly with **`Rcpp::interfaces(cpp)`**.\n\n#### 2. Support for Exporting Functions Inside Namespaces\n- Functions within namespaces can now be exported, as long as a **forward declaration** is provided with `cpp_name` in `Rcpp::export`.\n- This ensures proper symbol resolution while allowing structured code organization.\n\n#### 3. Handling of Declaration Specifiers\n- The system now accounts for **one and only one declaration specifier**:\n  - `template` → Used for **explicit template instantiations**.\n  - `inline` → Supports **functions defined inside headers**.\n- Combinations like `\"static inline\"` are **not supported** (e.g., `static` is explicitly disallowed).\n- An **inline function can still be forward-declared without the `inline` keyword**, and it will work seamlessly.\n\n#### 4. New `includes` Attribute for Header File Support\n- Since **Rcpp does not scan for header files**, a new `Rcpp::includes` attribute has been introduced.\n- This allows specifying one or more header file paths, ensuring necessary definitions are available in the generated `.cpp` file.\n- This is especially important for **template functions**, as the compiler needs access to their full definitions in order to instantiate them correctly.\n\n### Example Usage\n\n```cpp\n// [[Rcpp::includes(\"helpers.h\")]]\n\n// [[Rcpp::export(name = \"A1\", cpp_name = \"A1\")]]\ntemplate NumericVector A\u003cNumericVector\u003e(size_t n);\n\n// [[Rcpp::export(name = \"A2\", cpp_name = \"A2\")]]\ntemplate NumericVector A\u003cNumericVector\u003e(NumericVector x);\n\n// [[Rcpp::export(name = \"A3\", cpp_name = \"A3\")]]\nNumericVector Test::G();\n```\n\n### Generated Rcpp Export File\n\n```cpp\n// A\u003cNumericVector\u003e\ntemplate NumericVector A\u003cNumericVector\u003e(size_t n);\nRcppExport SEXP _testRcpp_A1(SEXP nSEXP) {\nBEGIN_RCPP\n    Rcpp::RObject rcpp_result_gen;\n    Rcpp::RNGScope rcpp_rngScope_gen;\n    Rcpp::traits::input_parameter\u003c size_t \u003e::type n(nSEXP);\n    rcpp_result_gen = Rcpp::wrap(A\u003cNumericVector\u003e(n));\n    return rcpp_result_gen;\nEND_RCPP\n}\n\n// A\u003cNumericVector\u003e\ntemplate NumericVector A\u003cNumericVector\u003e(NumericVector x);\nRcppExport SEXP _testRcpp_A2(SEXP xSEXP) {\nBEGIN_RCPP\n    Rcpp::RObject rcpp_result_gen;\n    Rcpp::RNGScope rcpp_rngScope_gen;\n    Rcpp::traits::input_parameter\u003c NumericVector \u003e::type x(xSEXP);\n    rcpp_result_gen = Rcpp::wrap(A\u003cNumericVector\u003e(x));\n    return rcpp_result_gen;\nEND_RCPP\n}\n\n// Test::G\nNumericVector Test::G();\nRcppExport SEXP _testRcpp_A3() {\nBEGIN_RCPP\n    Rcpp::RObject rcpp_result_gen;\n    Rcpp::RNGScope rcpp_rngScope_gen;\n    rcpp_result_gen = Rcpp::wrap(Test::G());\n    return rcpp_result_gen;\nEND_RCPP\n}\n\nstatic const R_CallMethodDef CallEntries[] = {\n    {\"_testRcpp_A1\", (DL_FUNC) \u0026_testRcpp_A1, 1},\n    {\"_testRcpp_A2\", (DL_FUNC) \u0026_testRcpp_A2, 1},\n    {\"_testRcpp_A3\", (DL_FUNC) \u0026_testRcpp_A3, 0},\n    {NULL, NULL, 0}\n};\n```\n\n### Testing \u0026 Future Considerations\nI have run extensive tests to ensure this new feature works correctly. The ability to export template and namespaced functions integrates well with the existing Rcpp framework. However, given the complexity of C++ templates and namespaces, there might still be edge cases that I haven’t encountered.\n\nWould this be a feature that the maintainers would be interested in? If so, I would be happy to prepare a pull request.\n\n","author":{"url":"https://github.com/ManosPapadakis95","@type":"Person","name":"ManosPapadakis95"},"datePublished":"2025-03-21T17:40:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":49},"url":"https://github.com/1368/Rcpp/issues/1368"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:c508d72a-5f3b-c69e-436b-45e045c0d15b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDCF0:65405:5594D2:720757:69715E26
html-safe-noncedb209d207be140011cb1ac6c6cf14e0f94ea12d3ba92084b6991190c0f8942fb
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQ0YwOjY1NDA1OjU1OTREMjo3MjA3NTc6Njk3MTVFMjYiLCJ2aXNpdG9yX2lkIjoiNTU1MzA2NTE2ODQwNjE0MjUwMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac9c8b94f6227ea7577eb0618c2c21fc78004a2321dd23bda0a3c0b9cf3bbd277d
hovercard-subject-tagissue:2939072367
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/RcppCore/Rcpp/1368/issue_layout
twitter:imagehttps://opengraph.githubassets.com/5b4efbe1e2f3e1b8c91872a11d908cc115229ac2cd8ca4ade9e2e2eaa1248fd6/RcppCore/Rcpp/issues/1368
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/5b4efbe1e2f3e1b8c91872a11d908cc115229ac2cd8ca4ade9e2e2eaa1248fd6/RcppCore/Rcpp/issues/1368
og:image:altEnhancement: Support for Exporting Template and Namespaced Functions in Rcpp Rcpp has been an incredible tool for bridging R and C++, and its flexibility has inspired me to explore new ways to exte...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameManosPapadakis95
hostnamegithub.com
expected-hostnamegithub.com
None1c338feb2465fb28789c852d4d9bbb3a30c0620671d1df7914edfbde84531d5e
turbo-cache-controlno-preview
go-importgithub.com/RcppCore/Rcpp git https://github.com/RcppCore/Rcpp.git
octolytics-dimension-user_id5811336
octolytics-dimension-user_loginRcppCore
octolytics-dimension-repository_id14005591
octolytics-dimension-repository_nwoRcppCore/Rcpp
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id14005591
octolytics-dimension-repository_network_root_nwoRcppCore/Rcpp
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseca28321bb5dd58db88720c48080666bfbe28520a
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/RcppCore/Rcpp/issues/1368#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2FRcppCore%2FRcpp%2Fissues%2F1368
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2FRcppCore%2FRcpp%2Fissues%2F1368
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=RcppCore%2FRcpp
Reloadhttps://patch-diff.githubusercontent.com/RcppCore/Rcpp/issues/1368
Reloadhttps://patch-diff.githubusercontent.com/RcppCore/Rcpp/issues/1368
Reloadhttps://patch-diff.githubusercontent.com/RcppCore/Rcpp/issues/1368
RcppCore https://patch-diff.githubusercontent.com/RcppCore
Rcpphttps://patch-diff.githubusercontent.com/RcppCore/Rcpp
Please reload this pagehttps://patch-diff.githubusercontent.com/RcppCore/Rcpp/issues/1368
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2FRcppCore%2FRcpp
Fork 221 https://patch-diff.githubusercontent.com/login?return_to=%2FRcppCore%2FRcpp
Star 784 https://patch-diff.githubusercontent.com/login?return_to=%2FRcppCore%2FRcpp
Code https://patch-diff.githubusercontent.com/RcppCore/Rcpp
Issues 4 https://patch-diff.githubusercontent.com/RcppCore/Rcpp/issues
Pull requests 2 https://patch-diff.githubusercontent.com/RcppCore/Rcpp/pulls
Discussions https://patch-diff.githubusercontent.com/RcppCore/Rcpp/discussions
Actions https://patch-diff.githubusercontent.com/RcppCore/Rcpp/actions
Projects 0 https://patch-diff.githubusercontent.com/RcppCore/Rcpp/projects
Wiki https://patch-diff.githubusercontent.com/RcppCore/Rcpp/wiki
Security Uh oh! There was an error while loading. Please reload this page. https://patch-diff.githubusercontent.com/RcppCore/Rcpp/security
Please reload this pagehttps://patch-diff.githubusercontent.com/RcppCore/Rcpp/issues/1368
Insights https://patch-diff.githubusercontent.com/RcppCore/Rcpp/pulse
Code https://patch-diff.githubusercontent.com/RcppCore/Rcpp
Issues https://patch-diff.githubusercontent.com/RcppCore/Rcpp/issues
Pull requests https://patch-diff.githubusercontent.com/RcppCore/Rcpp/pulls
Discussions https://patch-diff.githubusercontent.com/RcppCore/Rcpp/discussions
Actions https://patch-diff.githubusercontent.com/RcppCore/Rcpp/actions
Projects https://patch-diff.githubusercontent.com/RcppCore/Rcpp/projects
Wiki https://patch-diff.githubusercontent.com/RcppCore/Rcpp/wiki
Security https://patch-diff.githubusercontent.com/RcppCore/Rcpp/security
Insights https://patch-diff.githubusercontent.com/RcppCore/Rcpp/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/RcppCore/Rcpp/issues/1368
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/RcppCore/Rcpp/issues/1368
Support for Exporting Template and Namespaced Functions in Rcpphttps://patch-diff.githubusercontent.com/RcppCore/Rcpp/issues/1368#top
https://github.com/ManosPapadakis95
https://github.com/ManosPapadakis95
ManosPapadakis95https://github.com/ManosPapadakis95
on Mar 21, 2025https://github.com/RcppCore/Rcpp/issues/1368#issue-2939072367
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.