/*
 * Copyright (C) 2020-2021 Aloysius Indrayanto
 *
 * This file is part of the eCxx library, see LICENSE file for the license details.
 */


#ifndef ECXX_CTL_INITIALIZER_LIST_H
#define ECXX_CTL_INITIALIZER_LIST_H


#include <stddef.h>


namespace std {


    //
    // Emulate std::initializer_list<> as minimum as possible
    //
    template<class ValueT>
    class initializer_list {
        public:
            constexpr size_t size() const noexcept
            { return _size; }

            constexpr const ValueT* begin() const noexcept
            { return _array; }

            constexpr const ValueT* end() const noexcept
            { return _array + _size; }

        private:
            constexpr initializer_list() noexcept
            : _array(nullptr)
            , _size (0)
            {}

            constexpr initializer_list(const ValueT* array, size_t size)
            : _array(array)
            , _size (size)
            {}

        private:
            const ValueT* _array;
            size_t        _size;
    };


} // namespace std


namespace eCxx {

    template<typename ValueT>
    using InitializerList = std::initializer_list<ValueT>;

} // namespace eCxx


#endif
