mercredi 28 novembre 2018

std::tuple equivalent of std::pair's second member?

I'm converting this function to use std::tuple which does not have first and second memebers like std:pair.

std::type_index argumentType(const std::string& name) const
{
    return std::find_if(args_.begin(), args_.end(),
        [&name](std::pair<std::string, std::type_index> arg)->bool
        {
            return arg.first == name;
        }
    )->second;
}

I'm confused by the syntax ->second, what is this doing? and is thre equivalent std::get<1>(arg)

std::type_index argType(const std::string& name) const
{
    return std::find_if(args_.begin(), args_.end(),
        [&name](std::tuple<std::string, std::type_index, Attribute> arg)->bool
        {
            return std::get<0>(arg) == name;
        }
    )std::get<1>(arg);

Aucun commentaire:

Enregistrer un commentaire