Jednaki opseg

Napisati funkciju:

template <typename ForwardIt1, typename ForwardIt2>
bool all_equal(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2);

koja vraća true ako su svi elementi u opsegu [first1, last1) jednaki odgovarajućim elementima počevši od first2, a false inače. Pretpostaviti da tip elemenata podržava operator==, i da drugi opseg ima dovoljno elemenata.

Test

#include <iostream>
#include <vector>
#include <list>
#include <string>

namespace matf {
	 
	template <typename ForwardIt1, typename ForwardIt2>
	bool all_equal(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2)
	{
        // Ovde ide vasa implementacija
	}

} // namespace matf

int main(void)
{
	std::cout << std::boolalpha;

	std::vector<int> vec1 = { 3, 1, 4, 4, 5, 9, 2 };
	std::list<int> list1 = { 3, 1, 4, 4, 5, 9, 2 };

	std::cout << "All equal: " 
			  << matf::all_equal(vec1.begin(), vec1.end(), list1.begin()) 
			  << std::endl; // Output: true

	std::vector<char> vec2 = { 'a', 'b', 'c' };
	std::string str2 = "abc";

	std::cout << "All equal: " 
			  << matf::all_equal(vec2.begin(), vec2.end(), str2.begin()) 
			  << std::endl; // Output: true

	return 0;
}

Rešenje