/* *****************************************************************************
* kblib is a general utility library for C++14 and C++17, intended to provide
* performant high-level abstractions and more expressive ways to do simple
* things.
*
* Copyright (c) 2021 killerbee
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
* ****************************************************************************/
/**
* @file
* @brief Provides generic operations for containers, as well as kblib::stack.
*
* @author killerbee
* @date 2019-2021
* @copyright GNU General Public Licence v3.0
*/
#ifndef KBLIB_CONTAINERS_H
#define KBLIB_CONTAINERS_H
#include "fakestd.h"
#include "iterators.h"
#include "tdecl.h"
#include "traits.h"
#include
#include
#include
#include
#include
#include
#include
namespace KBLIB_NS {
template
KBLIB_NODISCARD constexpr auto pop(C& s) -> typename C::value_type {
typename C::value_type ret = std::move(s.top());
s.pop();
return ret;
}
template
KBLIB_NODISCARD constexpr auto get_or(const C& m, const K& key, const V& defval)
-> typename C::mapped_type {
auto it = m.find(key);
if (it == m.end())
return defval;
else
return it->second;
}
template
KBLIB_NODISCARD constexpr auto try_get(Map& map, Key&& key)
-> copy_const_t