33 lines
951 B
C++
33 lines
951 B
C++
#include "Easyfind.hpp"
|
|
#include <iostream>
|
|
#include <vector>
|
|
#include <list>
|
|
int main()
|
|
{
|
|
std::vector<int> vec;
|
|
vec.push_back(10);
|
|
vec.push_back(42);
|
|
vec.push_back(56);
|
|
vec.push_back(87);
|
|
std::cout << "Test vector container" << std::endl << "Find 42 (pos 2)" << std::endl;
|
|
std::vector<int>::iterator it = easyfind(vec, 42);
|
|
std::cout << "Find " << *it << std::endl;
|
|
|
|
std::list<int> lst;
|
|
lst.push_back(10);
|
|
lst.push_back(47);
|
|
lst.push_back(42);
|
|
lst.push_back(87);
|
|
std::cout << "Test list container" << std::endl << "Find 42 (pos 3)" << std::endl;
|
|
std::list<int>::iterator it2 = easyfind(lst, 42);
|
|
std::cout << "Find " << *it2 << std::endl;
|
|
|
|
std::cout << "Test vector container" << std::endl << "Find 41 (not here !)" << std::endl;
|
|
try {
|
|
std::vector<int>::iterator it3 = easyfind(vec, 41);
|
|
std::cout << "found " << *it3 << std::endl;
|
|
} catch (std::exception &e) {
|
|
std::cout << "Exeption catch : not found !" << std::endl;
|
|
}
|
|
}
|