기본 콘텐츠로 건너뛰기

bind2nd 컴파일 오류

아래와 같은 소스에서 bind2nd에서 컴파일 오류가 난다.

#include <list>
#include <algorithm>
#include <functional>
using namespace std;

typedef struct mystorage
{
    int i;
    char c;
} mystorage;

typedef list<char*> mylist;

inline
bool
check(const mystorage& s, int id)
{
    return s.i == id;
}

int
main(int,char**)
{
    mylist lst;
    mylist::iterator ib;

    bind2nd(ptr_fun(check), 10);

    return 0;
}
아래는 컴파일과 오류이다.
$ g++ -c bind2nd.cpp
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_function.h: In instantiation of ‘std::binder2nd<std::pointer_to_binary_function<const mystorage&, int, bool> >’:
/home/daldev/purewell/stuff/pwprj/src/bind2nd/main.cpp:27:   instantiated from here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_function.h:439: error: forming reference to reference type ‘const mystorage&’
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_function.h:445: error: forming reference to reference type ‘const mystorage&’
보면 "forming reference to reference type"이라는 문구가 보이는데, 이는 레퍼런스를 레퍼런스하는 객체를 만들 수 없다는 것이다. "const mystorage&&" 같은 형태를 만들 수 없다는 말인데...

그럼 위 소스에서 find_if/for_each를 위해 비교 class를 만들어야하나!? 귀찮게스리...


덧글: 제길! 알려진 버그란다. 막고 품던지 boost 쓰라는데... 참조

Powered by ScribeFire.

댓글

이 블로그의 인기 게시물

Winget 해시 무시하기

가끔씩 Winget 에서 패키지를 다운로드 했을 때, "설치 관리자 해시가 일치하지 않습니다." 오류가 뜰 때가 있다. 보안 이슈가 있지만, 그냥 무시하고 싶을 때, 아래 순서로 무시해준다. 관리자 권한 winget settings --enable InstallerHashOverride 설치 winget install --ignore-security-hash --id NirSoft.NirCmd