-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_check_it_category.hpp
35 lines (31 loc) · 2.42 KB
/
ft_check_it_category.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fun.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ninieddu <ninieddu@student.42lyon.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/21 09:40:35 by ninieddu #+# #+# */
/* Updated: 2022/02/21 10:20:50 by ninieddu ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <typeinfo> // typeid
#include <string>
#include "iterators/ft_iterator_traits.hpp"
// https://www.youtube.com/watch?v=yTi46Pb32qg
template<class T>
std::string get_iterator_type (T)
{
if (typeid (typename ft::iterator_traits<T>::iterator_category) == typeid (ft::input_iterator_tag)) return "Input";
else if (typeid (typename ft::iterator_traits<T>::iterator_category) == typeid (ft::output_iterator_tag)) return "Output";
else if (typeid (typename ft::iterator_traits<T>::iterator_category) == typeid (ft::forward_iterator_tag)) return "Forward";
else if (typeid (typename ft::iterator_traits<T>::iterator_category) == typeid (ft::bidirectional_iterator_tag)) return "Bidirectional";
else if (typeid (typename ft::iterator_traits<T>::iterator_category) == typeid (ft::random_access_iterator_tag)) return "Random Access";
// STD check :
else if (typeid (typename std::iterator_traits<T>::iterator_category) == typeid (std::input_iterator_tag)) return "Input";
else if (typeid (typename std::iterator_traits<T>::iterator_category) == typeid (std::output_iterator_tag)) return "Output";
else if (typeid (typename std::iterator_traits<T>::iterator_category) == typeid (std::forward_iterator_tag)) return "Forward";
else if (typeid (typename std::iterator_traits<T>::iterator_category) == typeid (std::bidirectional_iterator_tag)) return "Bidirectional";
else if (typeid (typename std::iterator_traits<T>::iterator_category) == typeid (std::random_access_iterator_tag)) return "Random Access";
return "missing";
}