Skip to the content.

:heavy_check_mark: adaptor/auto_expander.hpp

Depends on

Required by

Verified with

Code

#pragma once


#include <functional>
#include <optional>
#include <cassert>


#include "internal/dev_env.hpp"
#include "internal/types.hpp"


namespace uni {


template<class Container>
struct auto_expander : Container {
    using size_type = Container::size_type;

  public:
    template<class... Args>
    explicit auto_expander(Args&&... args) noexcept(NO_EXCEPT) : Container(std::forward<Args>(args)...) {}

    inline auto& operator[](const size_type pos) noexcept(NO_EXCEPT) {
        if(this->size() <= pos) this->Container::resize(pos + 1);
        return this->Container::operator[](pos);
    }
};


}
#line 2 "adaptor/auto_expander.hpp"


#include <functional>
#include <optional>
#include <cassert>


#line 2 "internal/dev_env.hpp"


#ifdef LOCAL_JUDGE
    inline constexpr bool DEV_ENV = true;
    inline constexpr bool NO_EXCEPT = false;
#else
    inline constexpr bool DEV_ENV = false;
    inline constexpr bool NO_EXCEPT = true;
#endif // LOCAL_JUDGE


#if __cplusplus >= 202100L
    #define CPP20 true
    #define CPP23 true
#elif __cplusplus >= 202002L
    #define CPP20 true
    #define CPP23 false
#else
    #define CPP20 false
    #define CPP23 false
#endif
#line 2 "internal/types.hpp"

#include <cstdint>

namespace uni {

namespace internal {


using size_t = std::int64_t;

using int128_t = __int128_t;
using uint128_t = __uint128_t;


} // namesapce internal

} // namespace uni
#line 11 "adaptor/auto_expander.hpp"


namespace uni {


template<class Container>
struct auto_expander : Container {
    using size_type = Container::size_type;

  public:
    template<class... Args>
    explicit auto_expander(Args&&... args) noexcept(NO_EXCEPT) : Container(std::forward<Args>(args)...) {}

    inline auto& operator[](const size_type pos) noexcept(NO_EXCEPT) {
        if(this->size() <= pos) this->Container::resize(pos + 1);
        return this->Container::operator[](pos);
    }
};


}
Back to top page