将数组转换为C ++中的设置 [英] Convert array to set in C++

查看:70
本文介绍了将数组转换为C ++中的设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有更简单的方法可以使用c ++将数组转换为集合而不是遍历其元素?

Is there an easier way to turn an array in to a set using c++ rather than looping through its elements?

最好使用标准模板库

推荐答案

对于所有标准库容器类型,请使用构造函数:

As for all standard library container types, use the constructor:

std::set<T> set(begin(array), end(array));

这篇关于将数组转换为C ++中的设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆