Skip to content

Commit 5e508df

Browse files
committed
Ensure the constness of the data member
1 parent 42b3bda commit 5e508df

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cpp/custom-dataset/custom-dataset.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ using Data = std::vector<std::pair<std::string, long>>;
2626
class CustomDataset : public torch::data::datasets::Dataset<CustomDataset> {
2727
using Example = torch::data::Example<>;
2828

29-
Data data;
29+
const Data data;
3030

3131
public:
3232
CustomDataset(const Data& data) : data(data) {}
@@ -198,7 +198,7 @@ int main() {
198198
std::cout << "Running on: "
199199
<< (options.device == torch::kCUDA ? "CUDA" : "CPU") << std::endl;
200200

201-
auto data = readInfo();
201+
const auto data = readInfo();
202202

203203
auto train_set =
204204
CustomDataset(data.first).map(torch::data::transforms::Stack<>());

0 commit comments

Comments
 (0)