내가 내 질문에 좀 더 명확하게하기 위해 다음과 같은 코드를 제공합니다 :왜 컨테이너의 기본 요소가 boost :: tuple 일 때 std :: find를 사용할 수 없습니까?
bool bFind;
boost::tuple<int> abc;
//int abc;
std::vector<boost::tuple<int> > myArray;
//std::vector<int> myArray;
bFind = is_vector_contains(myArray,abc);
is_vector_contains하는 템플릿 함수입니다 :
template<typename T>
bool is_vector_contains(const std::vector<T> &vecArray, const T &element)
{
if(std::find(vecArray.begin(),vecArray.end(),element) == vecArray.end())
return false;
else
return true;
}
나는 위의 코드를 컴파일 할 때, 나는 다음과 같은 컴파일 오류가 있습니다
을Error 1 error C2678: binary '==' : no operator found which takes a left-hand operand of type 'const boost::tuples::tuple<T0>' (or there is no acceptable conversion)
아이디어가 있으십니까? 이 방법으로 등호 연산자를 정의하려고 시도했지만 컴파일에 성공하지 못했습니다.
bool operator == (const boost::tuple<int> &a, const boost::tuple<int> &b)
{
return true;
}
그래서, 당신이 이해하기 위해 무엇을하려고 했습니까? 'boost :: tuple' 문서를 확인 했습니까? (우연히도, 저는 여러분의 함수 이름이'is_vector_contains()'가 다소 이상합니다.). – Walter
@Waller 감사합니다. 당신이 제안한대로 설명서를 읽었을 때 대답과 동일한 대답을 발견했습니다. – feelfree