sizeof... operator - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# sizeof... operator

From cppreference.com
< cpp‎ | language

Queries the number of elements in a parameter pack.

### [edit] Syntax

`sizeof...(` parameter_pack `)` |  | (since C++11)

Returns a constant of type std::size_t.

### [edit] Explanation

Returns the number of elements in a parameter pack.

### [edit] Keywords

`sizeof`

### [edit] Example

Run this code

    #include <iostream>
    #include <array>

    template<typename... Ts>
    constexpr auto make_array(Ts&&... ts)
        -> std::array<std::common_type_t<Ts...>,sizeof...(ts)>
    {
        return { std::forward<Ts>(ts)... };
    }

    int main()
    {
        auto b = make_array(1, 2, 3);
        std::cout << b.size() << '\n';
        for (auto i : b)
            std::cout << i << ' ';
    }

Output:

    3
    1 2 3

### [edit] See also

- sizeof

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/language/sizeof...&oldid=75831"