fork download
#include 
#include 
#include 

template < typename T, std::size_t N > struct c_array
{
    static_assert( std::is_pod::value, "must be a pod!" ) ;
    static_assert( N, "size must be a non-zero!" ) ;

    c_array() : a { T() } {}
    template < typename... U > c_array( U&&... args ) : a { args... } {} // ??

    T& operator[] ( std::size_t p ) { return a[p] ; }
    const T& operator[] ( std::size_t p ) const { return a[p] ; }

    T* begin() { return std::begin(a) ; }
    T* end() { return std::end(a) ; }
    const T* begin() const { return std::begin(a) ; }
    const T* end() const { return std::end(a) ; }

    T a[N] ;
};

int main()
{
    c_array a ;
    for( auto i : a ) std::cout << i << ' ' ; std::cout << '\n' ;

    c_array b { 1, 2, 3, 4 };
    for( auto i : b ) std::cout << i << ' ' ; std::cout << '\n' ;
}
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
0 0 0 0 0 
1 2 3 4 0 0