Function at

Synopsis

#include <include/type_safe/index.hpp>

template <typename Indexable>
auto at(Indexable &&obj, const index_t &index) -> decltype(std::forward< Indexable >(obj)[static_cast< std::size_t >(get(index))])

Description

Returns
The ith element of obj by invoking its operator[] with the [ts::index_t]() converted to std::size_t. \requires index must be a valid index for obj, i.e. less than the size of obj. \exclude return \module types

Source

Lines 182-190 in include/type_safe/index.hpp.

template <typename Indexable>
auto at(Indexable&& obj, const index_t& index)
    -> decltype(std::forward<Indexable>(obj)[static_cast<std::size_t>(get(index))])
{
    DEBUG_ASSERT(detail::index_valid(detail::member_size{}, obj,
                                     static_cast<std::size_t>(get(index))),
                 detail::precondition_error_handler{});
    return std::forward<Indexable>(obj)[static_cast<std::size_t>(get(index))];
}





Add Discussion as Guest

Log in