Compiler error: no matching member function for call to 'assign'

Hi everyone,

I got the following compile error msgs and I cannot locate which code triggered this. Can someone help me to interpret the compilation message?

thanks a lot!
chuuuing

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[  9%] Building CXX object src/planner/expression/CMakeFiles/duckdb_planner_expression.dir/ub_duckdb_planner_expression.cpp.o
In file included from /Users/chuyinghe/Documents/duckdb-master-rl/cmake-build-debug/src/optimizer/pushdown/ub_duckdb_optimizer_pushdown.cpp:2:
In file included from /Users/chuyinghe/Documents/duckdb-master-rl/src/optimizer/pushdown/pushdown_aggregate.cpp:1:
In file included from /Users/chuyinghe/Documents/duckdb-master-rl/src/include/duckdb/optimizer/filter_pushdown.hpp:12:
In file included from /Users/chuyinghe/Documents/duckdb-master-rl/src/include/duckdb/optimizer/filter_combiner.hpp:11:
In file included from /Users/chuyinghe/Documents/duckdb-master-rl/src/include/duckdb/common/types/value.hpp:12:
In file included from /Users/chuyinghe/Documents/duckdb-master-rl/src/include/duckdb/common/exception.hpp:13:
In file included from /Users/chuyinghe/Documents/duckdb-master-rl/src/include/duckdb/common/vector.hpp:11:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/vector:1404:9: error: no matching member function for call to 'assign'
        assign(__x.__begin_, __x.__end_);
        ^~~~~~
/Users/chuyinghe/Documents/duckdb-master-rl/src/include/duckdb/common/types/chunk_collection.hpp:25:7: note: in instantiation of member function 'std::__1::vector<std::__1::unique_ptr<duckdb::DataChunk, std::__1::default_delete<duckdb::DataChunk> >, std::__1::allocator<std::__1::unique_ptr<duckdb::DataChunk, std::__1::default_delete<duckdb::DataChunk> > > >::operator=' requested here
class ChunkCollection {
      ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/vector:611:10: note: candidate function not viable: no known conversion from 'const std::__1::__vector_base<std::__1::unique_ptr<duckdb::DataChunk, std::__1::default_delete<duckdb::DataChunk> >, std::__1::allocator<std::__1::unique_ptr<duckdb::DataChunk, std::__1::default_delete<duckdb::DataChunk> > > >::pointer' (aka 'std::__1::unique_ptr<duckdb::DataChunk, std::__1::default_delete<duckdb::DataChunk> > *const') to 'std::__1::vector<std::__1::unique_ptr<duckdb::DataChunk, std::__1::default_delete<duckdb::DataChunk> >, std::__1::allocator<std::__1::unique_ptr<duckdb::DataChunk, std::__1::default_delete<duckdb::DataChunk> > > >::size_type' (aka 'unsigned long') for 1st argument
    void assign(size_type __n, const_reference __u);
         ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/vector:599:9: note: candidate template ignored: requirement '!__is_cpp17_forward_iterator<std::__1::unique_ptr<duckdb::DataChunk, std::__1::default_delete<duckdb::DataChunk> > *>::value' was not satisfied [with _InputIterator = std::__1::unique_ptr<duckdb::DataChunk, std::__1::default_delete<duckdb::DataChunk> > *]
        assign(_InputIterator __first, _InputIterator __last);
        ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/vector:609:9: note: candidate template ignored: requirement 'is_constructible<std::__1::unique_ptr<duckdb::DataChunk, std::__1::default_delete<duckdb::DataChunk> >, std::__1::unique_ptr<duckdb::DataChunk, std::__1::default_delete<duckdb::DataChunk> > &>::value' was not satisfied [with _ForwardIterator = std::__1::unique_ptr<duckdb::DataChunk, std::__1::default_delete<duckdb::DataChunk> > *]
        assign(_ForwardIterator __first, _ForwardIterator __last);
        ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/vector:615:10: note: candidate function not viable: requires single argument '__il', but 2 arguments were provided
    void assign(initializer_list<value_type> __il)
Last edited on
Hello chuuuing,


I got the following compile error msgs and I cannot locate which code triggered this.


I do not have any idea what code triggered any of the errors either because you did not provide any code to go with the error messages.

My first thought is that using namespace std; is the first problem.

Andy
hi Andy,

thanks for replying. The reason I didn't put my code is that it's enormous. You can find the source code here: https://github.com/ChuyingHe/duckdb-master-rl.git

this is the file that I guess caused the problem:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//===----------------------------------------------------------------------===//
//                         DuckDB
//
// duckdb/common/types/chunk_collection.hpp
//
//
//===----------------------------------------------------------------------===//

#pragma once

#include "duckdb/common/enums/order_type.hpp"
#include "duckdb/common/types/data_chunk.hpp"
#include "duckdb/common/winapi.hpp"

namespace duckdb {

//!  A ChunkCollection represents a set of DataChunks that all have the same
//!  types
/*!
    A ChunkCollection represents a set of DataChunks concatenated together in a
   list. Individual values of the collection can be iterated over using the
   iterator. It is also possible to iterate directly over the chunks for more
   direct access.
*/
class ChunkCollection {
public:
	ChunkCollection() : count(0) {
	}

    void swap( ChunkCollection& other)
    {
        using std::swap;
        swap(count, other.count);
        swap(chunks, other.chunks);
        swap(types, other.types);
    }

	ChunkCollection(ChunkCollection& cc) {
	    count = cc.count;
	    chunks.reserve(cc.chunks.size());
        for (auto const &elem:cc.chunks) {
            chunks.push_back(elem->clone());
        }
        types = cc.types;
	}


	unique_ptr<ChunkCollection> Copy() {
        return make_unique<ChunkCollection>(*this);
	}

    shared_ptr<ChunkCollection> duplicate() {
        return make_shared<ChunkCollection>(*this);
    }

	//! The amount of columns in the ChunkCollection
	DUCKDB_API vector<LogicalType> &Types() {
		return types;
	}
	const vector<LogicalType> &Types() const {
		return types;
	}

	//! The amount of rows in the ChunkCollection
	DUCKDB_API const idx_t &Count() const {
		return count;
	}

	//! The amount of columns in the ChunkCollection
	DUCKDB_API idx_t ColumnCount() const {
		return types.size();
	}

	//! Append a new DataChunk directly to this ChunkCollection
	DUCKDB_API void Append(DataChunk &new_chunk);

	//! Append another ChunkCollection directly to this ChunkCollection
	DUCKDB_API void Append(ChunkCollection &other);

	//! Merge is like Append but messes up the order and destroys the other collection
	DUCKDB_API void Merge(ChunkCollection &other);

	DUCKDB_API void Verify();

	//! Gets the value of the column at the specified index
	DUCKDB_API Value GetValue(idx_t column, idx_t index);
	//! Sets the value of the column at the specified index
	DUCKDB_API void SetValue(idx_t column, idx_t index, const Value &value);

	DUCKDB_API vector<Value> GetRow(idx_t index);

	DUCKDB_API string ToString() const {
		return chunks.size() == 0 ? "ChunkCollection [ 0 ]"
		                          : "ChunkCollection [ " + std::to_string(count) + " ]: \n" + chunks[0]->ToString();
	}
	DUCKDB_API void Print();

	//! Gets a reference to the chunk at the given index
	DUCKDB_API DataChunk &GetChunkForRow(idx_t row_index) {
		return *chunks[LocateChunk(row_index)];
	}

	//! Gets a reference to the chunk at the given index
	DUCKDB_API DataChunk &GetChunk(idx_t chunk_index) {
		D_ASSERT(chunk_index < chunks.size());
		return *chunks[chunk_index];
	}
	const DataChunk &GetChunk(idx_t chunk_index) const {
		D_ASSERT(chunk_index < chunks.size());
		return *chunks[chunk_index];
	}

	DUCKDB_API const vector<unique_ptr<DataChunk>> &Chunks() {
		return chunks;
	}

	DUCKDB_API idx_t ChunkCount() const {
		return chunks.size();
	}

	DUCKDB_API void Reset() {
		count = 0;
		chunks.clear();
		types.clear();
	}

	DUCKDB_API unique_ptr<DataChunk> Fetch() {
		if (ChunkCount() == 0) {
			return nullptr;
		}

		auto res = move(chunks[0]);
		chunks.erase(chunks.begin() + 0);
		return res;
	}

	DUCKDB_API void Sort(vector<OrderType> &desc, vector<OrderByNullType> &null_order, idx_t result[]);
	//! Reorders the rows in the collection according to the given indices.
	DUCKDB_API void Reorder(idx_t order[]);

	DUCKDB_API void MaterializeSortedChunk(DataChunk &target, idx_t order[], idx_t start_offset);

	//! Returns true if the ChunkCollections are equivalent
	DUCKDB_API bool Equals(ChunkCollection &other);

	//! Locates the chunk that belongs to the specific index
	DUCKDB_API idx_t LocateChunk(idx_t index) {
		idx_t result = index / STANDARD_VECTOR_SIZE;
		D_ASSERT(result < chunks.size());
		return result;
	}

	DUCKDB_API void Heap(vector<OrderType> &desc, vector<OrderByNullType> &null_order, idx_t heap[], idx_t heap_size);
	DUCKDB_API idx_t MaterializeHeapChunk(DataChunk &target, idx_t order[], idx_t start_offset, idx_t heap_size);

private:
	//! The total amount of elements in the collection
	idx_t count;
	//! The set of data chunks in the collection
	vector<unique_ptr<DataChunk>> chunks;
	//! The types of the ChunkCollection
	vector<LogicalType> types;
};
} // namespace duckdb


Best,
Chuying
Of help in the future, I suggest only writing a small chunk of code (no more than about 20 lines or so) then compiling and then testing. Any issues are then related to the last written chunk. So it's fairly easy to narrow the issue down to the culprit.

Another issue that can cause multiple difficult to decipher errors is miss-matching braces.
Last edited on
What would also be helpful - to you and us - is to try and create a minimal but complete codeset that, when you compile it, still exhibits the problem but no others. The chances are that, while doing that, you'll discover what the problem is yourself, because you'll discover which bit of code is causing the problem, but even if you can't, you'll at least have something manageable you can post here in its complete form, that we can look at.

So, try and create the smallest bit of code you can, that is still displaying the problem but is otherwise fine, and then we can work with that.
thanks for all the replies.

due to the size of the project, I cannot extract related code. But your suggestions are really insightful, I tried to implemented layer by layer, haven't finished it yet but i think it will work.

Thanks for the inspiration, you guys are amazing.

chuuuing

Registered users can post here. Sign in or register to post.