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

array_h

v1.0.2

Published

A C++ header-only library that provides an elegant way to construct arrays with variable arguments (数组的参展构造:一个C++单头文件库,提供优雅的可变参数数组构造方式)

Readme

Array Constructor (数组的参展构造)

一个C++单头文件库,提供优雅的可变参数数组构造方式,让std::vector用起来像原生数组一样直观。

核心特性

  • 直观的构造方式:使用Array(1, 2, 3)创建数组,语法简洁
  • 自动类型推导:根据第一个参数自动推导数组类型
  • 类型安全:确保所有参数类型一致
  • 兼容标准容器:返回std::vector,支持所有标准容器操作
  • 单头文件:无需编译,直接包含即可使用
  • 支持两种初始化方式:可变参数和初始化列表

安装方法

  1. 直接下载Array.h文件
  2. 放入你的项目目录中
  3. 在代码中包含该头文件:#include "Array.h"

使用示例

#include "Array.h"
#include <iostream>

int main() {
    // 基本用法:可变参数构造
    auto intArray = Array(10, 20, 30, 40, 50);
    auto doubleArray = Array(3.14, 2.718, 1.618);
    auto strArray = Array("apple", "banana", "cherry");
    
    // 初始化列表构造
    auto colorArray = Array({"red", "green", "blue"});
    
    // 像使用std::vector一样操作
    std::cout << "整数数组: ";
    for (int num : intArray) {
        std::cout << num << " ";
    }
    std::cout << std::endl;
    
    std::cout << "数组大小: " << intArray.size() << std::endl;
    std::cout << "第二个元素: " << intArray[1] << std::endl;
    
    return 0;
}

技术细节

  • 基于C++17:使用折叠表达式处理可变参数
  • 内部实现:基于std::vector,兼具安全性和灵活性
  • 类型推导:通过第一个参数推导数组类型,确保类型一致性

编译要求

  • 需要支持C++17或更高标准的编译器
  • 编译时添加-std=c++17选项

许可证

本项目采用MIT许可证 - 详见LICENSE文件

为什么叫"数组的参展构造"?

"参展构造"形象地描述了本库的核心功能:将多个参数有序地"展开"并"汇聚"成一个完整的数组,既直观又形象。


修改说明

  1. 将"参展构造"修正为更准确的"参展构造"
  2. 修复了代码块的格式问题,添加了正确的代码块标记
  3. 保持了原有的技术内容和结构
  4. 修正了标题中的拼写错误("的参展构造" → "的参展构造")