npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

parampack

v1.0.0

Published

C++原生ParamPack框架:实现参数复用与逆向绑定,支持任意类型参数的延迟执行

Readme

ParamPack框架官方文档

C++原生ParamPack框架,实现参数复用逆向绑定,支持任意类型、任意数量的参数,适用于C++11及以上版本。

核心优势

  • 原生C++:纯头文件实现,无依赖,直接#include即可使用;
  • 参数复用:一次设置参数,多次传递给不同函数(操作器);
  • 类型安全:编译期检查参数匹配,避免运行时错误;
  • 轻量级:仅50行核心代码,无性能开销。

安装方式

通过npm安装(需先安装Node.js,仅用于获取头文件):

# 全局安装(所有C++项目可共用)
npm install -g ParamPack

# 或局部安装(仅当前项目可用)
npm install --save-dev ParamPack

建议大家安装好后直接去node_modules把头文件复制到c++项目

快速使用示例

示例 1:基础参数复用(int + double + string)

#include"ParamPack.h" //注意头文件的位置自行调整

#include <iostream>

#include <string>

int main() {

 // 1. 创建参数包(int=10, double=20.5, string="hello")

 auto pack = createParamPack(10, 20.5, std::string("hello"));

 // 2. 执行操作1:打印参数

 pack.execute([](int a, double b, const std::string& c) {

   std::cout << "参数1:" << a << ", 参数2:" << b << ", 参数3:" << c << std::endl;

 });

 // 3. 执行操作2:计算结果(返回int)

 int result = pack.execute([](int a, double b, const std::string& c) {

   return a + static_cast<int>(b) + c.size();

 });

 std::cout << "计算结果:" << result << std::endl;  // 输出 10+20+5=35

 // 4. 更新参数包

 pack.updateParams(30, 40.5, std::string("world"));

 pack.execute([](int a, double b, const std::string& c) {

   std::cout << "更新后参数:" << a << ", " << b << ", " << c << std::endl;

 });

 return 0;

}

示例 2:自定义结构体参数(User 案例)

#include"ParamPack.h" //注意头文件的位置自行调整

#include <iostream>

#include <string>

// 自定义结构体

struct User {
	
	std::string name;
	
	int age;
	
	std::string email;
	
};

int main() {
	
	User user{"张三", 25, "[email protected]"};
	
	auto userPack = createParamPack(user);
	
	// 操作1:显示用户信息
	
	userPack.execute([](const User& u) {
		
		std::cout << "姓名:" << u.name << ", 年龄:" << u.age << ", 邮箱:" << u.email << std::endl;
		
	});
	
	// 操作2:验证用户信息
	
	bool isValid = userPack.execute([](const User& u) {
		
		return !u.name.empty() && u.age > 0 && u.email.find("@") != std::string::npos;
		
	});
	
	std::cout << "用户信息" << (isValid ? "有效" : "无效") << std::endl;
	
	return 0;
	
}   

版本更新日志

  • v1.0.0:初始版本,支持任意类型参数包、参数更新、多操作执行。

注意事项

  1. 需 C++11 及以上标准(支持模板参数包、lambda 表达式、std::tuple);

  2. 头文件路径需正确配置,否则会报 “无法找到 ParamPack.h” 错误;

  3. 操作器(lambda / 函数)的参数列表需与参数包完全匹配(类型、数量、顺序),否则编译报错。