기본 콘텐츠로 건너뛰기

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.

댓글

이 블로그의 인기 게시물

버즈 라이브 배터리 교체

나는 버즈 라이브(SM-R180)가 좋은데, 평가가 별루였는지, 해당 스타일로 버즈를 더 이상 만들지 않고 있다. 아무튼, 오래 쓴 버즈 라이브 배터리가 슬슬 맛이 가기 시작해서, 블로그 를 참조하면서 분해 및 교체를 하였다. (진짜 쉬움) 요로코롬 위아래를 살짝 눌러주면 뚜껑이 벌어진다. 안쪽 플라스틱은 오른쪽은 분홍색, 왼쪽은 회색이다. 리본 케이블 살짝 들어내고, 기판을 떼어내면, 작은 나사가 있다. 나사를 풀고, 플라스틱을 걷어내면, 검은 양면 테이프로 고정된 CR1254 배터리가 보인다. 잘 쑤셔서(?) 꺼낸다. 새로운 CR1254 배터리를 넣는다. 음극이 아래로 가도록 하고, 분해의 역순으로 조립하면 된다. 조립할 때, 아까 풀었던 나사는 잊지 말고 꼭 조여준다. (까먹고 조립해서 다시 뜯고 조립함) 충전도 잘 되고, 소리도 잘 나는거 보면, 조립도 잘 된 것 같다. 이렇게 버즈 라이브의 수명을 강제로 늘렸다. 나중에 본체 배터리도 갈아야겠다.

Windows 에서 절전을 깨우는 장치 찾기

참조:  https://www.reddit.com/r/computer/comments/wquswv/windows_11_pc_wakes_up_every_time_i_move_usb/ powercfg /devicequery wake_armed powercfg /deviceenablewake "[DEVICE]" # $PROFILE function Get-WakeArmedDevices { $devices = powercfg -devicequery wake_armed if ($devices) { $devices | ForEach-Object { $_.Trim() } } else { Write-Host "No devices are currently armed for wake events." } } function Set-EnableWakeOnDevice { param( [string]$deviceName ) sudo powercfg -deviceenablewake $deviceName } function Set-DisableWakeOnDevice { param( [string]$deviceName ) sudo powercfg -devicedisablewake $deviceName }