std::map one key, two values

前端 未结 3 1714
谎友^
谎友^ 2021-02-19 16:03

What is the best way to map two values to one key?

ie An item with a value and bool.

Tried using:

std::map

        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-19 16:50

    Either use std::pair<> as you did, or make a custom struct containing the values you want to store. I'd do the latter in most cases, as the values then have names more descriptive than first and second.

提交回复
热议问题