임 프로그램 A, I는 구조체가 다른 구조체를 사용하여 노드라고 선언하고 템플릿 클래스에 정의 된 NODE_TYPE라고 ab_int 내가 사용하고 lib 디렉토리 B에 의해 제공.자신의 구조체에 템플릿 클래스의 구조체를 사용하는 방법은 무엇입니까?
프로그램 A : LIB B에서 구조체 에게 NODE_TYPE이 포함 된 템플릿
struct Node {
int rank;
ab_int::node_type nt;
Node() : rank(), nt() {}
Node(int rank_new, ab_int::node_type nt_new) : rank(rank_new), nt(nt_new) {}
};
이된다, 또한 내가 원하는 기능 루트() LIB B에서
template<class t_bitvector = bit_vector, ...>
class ab_int
{
...
public:
struct node_type {
...
// Assignment operator
node_type& operator=(const node_type&) = default;
// Move assignment operator
node_type& operator=(node_type&&) = default;
...
}
...
node_type root() const {
return node_type(0, m_size, 0, 0);
}
...
}
있다 사용.
// wt instantiated (works!)
Node node;
node.rank = 1;
node.nt = wt.root();
나는 다음과 같은 컴파일 오류가 점점 오전 :
.../main.cpp:23:5: error: expected a class or namespace
ab_int::node_type nt;
^
.../main.cpp:26:44: error: expected a class or namespace
Node(int rank_new, ab_int::node_type nt_new) : rank(rank_new), nt(nt_new) {}
업데이트 1 :
을는 프로그램 A, 나는 노드 구조체의 새 인스턴스를 인스턴스화 할
ab_int::node_type
을 ab_int<>::node_type
으로 변경하면 다른 오류가 팝업 :
.../main.cpp:63:13: error: no viable overloaded '='
node.nt = wt.root();
~~~~~~~^~~~~~~~~~
.../ab_int.hpp:752:24: note: candidate function not viable: no known conversion from 'z::ab_int<z::rrr_vector<63, z::int_vector<'\x00'>, 32>, z::rank_support_rrr<'\x01', 63, z::int_vector<'\x00'>, 32>, z::select_support_rrr<'\x01', 63, z::int_vector<'\x00'>, 32>, z::select_support_rrr<'\x00', 63, z::int_vector<'\x00'>, 32> >::node_type' to 'const z::ab_int<z::int_vector<'\x01'>, z::rank_support_v<'\x01', '\x01'>, z::select_support_mcl<'\x01', '\x01'>, z::select_support_mcl<'\x00', '\x01'> >::node_type' for 1st argument
node_type& operator=(const node_type&) = default;
^
.../ab_int.hpp:755:24: note: candidate function not viable: no known conversion from 'z::ab_int<z::rrr_vector<63, z::int_vector<'\x00'>, 32>, z::rank_support_rrr<'\x01', 63, z::int_vector<'\x00'>, 32>, z::select_support_rrr<'\x01', 63, z::int_vector<'\x00'>, 32>, z::select_support_rrr<'\x00', 63, z::int_vector<'\x00'>, 32> >::node_type' to 'z::ab_int<z::int_vector<'\x01'>, z::rank_support_v<'\x01', '\x01'>, z::select_support_mcl<'\x01', '\x01'>, z::select_support_mcl<'\x00', '\x01'> >::node_type' for 1st argument
node_type& operator=(node_type&&) = default;
업데이트 2 :
을 두 번째 컴파일 오류가 개체 중량의 인스턴스에 대한 약간의 불일치와 관련이 있었다. 원래 질문과 관련이 없으므로 더 이상 논의하지 않습니다.
가
다른 질문을하기 위해 질문을 업데이트하지 마십시오. – Barry
두 번째 질문 인 'node.nt'와 'wt.root()'는 다른 유형이 있습니다 (첫 번째 템플릿 arg는 'z :: rrr_vector <>'와'z : int_vector <>'입니다). 다른 쪽). – Barry
it 's z : rrr_vector <>, 실수를 수정했습니다 ... – Scholle