나는 boost :: variant 내부에 두 종류의 std :: unique_ptr을 가지고있다. boost :: static_visitor의 하위 클래스를 작성하여 기본 객체에 const 참조를 추출하려고합니다. 두 개의 unique_ptr 변형을 boost :: variant에 템플릿으로 지정합니다.boost :: visitor를 unique_ptr의 boost :: variant와 함께 사용하기
using bitmap_flyweight_t = boost::flyweights::flyweight<allegro_bitmap_t>;
using image_bitmap_flyweight_t = boost::flyweights::flyweight<boost::flyweights::key_value<const char*, allegro_bitmap_t>>;
class bitmap_visitor : public boost::static_visitor<allegro_bitmap_t>
{
public:
const allegro_bitmap_t& operator()(const std::unique_ptr<bitmap_flyweight_t> bitmap_ptr) const
{
return bitmap_ptr.get()->get();
}
const allegro_bitmap_t& operator()(const std::unique_ptr<image_bitmap_flyweight_t> bitmap_ptr) const
{
return bitmap_ptr.get()->get();
}
};
내가 이동 의미, 거기에 어떤 컴파일러 불만을 사용하여 인스턴스에 객체의 부스트 :: 변형 멤버 변수에 unique_ptrs을 넣을 수 있어요 : 설치는 다음과 같이 보인다. 그러나 위의 방문자를 사용하여 variant 유형에 액세스하려고하면 unique_ptr이 복사 가능하지 않으므로 컴파일러에서이를 수행 할 수 없다고 불평합니다.
참조 수락을 시도한 적이 있습니까? – krzaq