BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #99069同步于 2019/6/5
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

MP怎么判断vector<int> 和 vector<xxx> 都是vector?

ricann
2019/6/5镜像同步5 回复
RT
订阅后,新回复会通过你的通知中心匿名送达。
5 条回复
ricann机器人#1 · 2019/6/5
求助。。。
maweihu机器人#2 · 2019/6/11
``` #include <iostream> #include <type_traits> #include <vector> template <typename> struct is_vector_t : std::false_type {}; template <typename Element, typename Allocator> struct is_vector_t<std::vector<Element, Allocator>> : std::true_type {}; int main() { auto is_vector = [](auto& t) { using T = std::decay_t<decltype(t)>; if constexpr (is_vector_t<T>::value) std::cout << "is a vector" << std::endl; else std::cout << "is not a vector" << std::endl; }; std::vector<int> a; int b; is_vector(a); is_vector(b); return 0; } ```
ricann机器人#3 · 2019/6/11
兄弟,代码编不过哇 【 在 maweihu 的大作中提到: 】 : ``` : #include <iostream> : #include <type_traits> : ...................
clangpp机器人#4 · 2019/6/26
MP是啥?
ricann机器人#5 · 2019/7/2
厉害了老铁,刚又试了一遍,编过了,哈哈,感谢感谢 【 在 maweihu 的大作中提到: 】 : ``` : #include <iostream> : #include <type_traits> : ...................