Skip to content

Commit 7511775

Browse files
minhthuc2502thucpham
andauthored
fix build with newer cxx 17 (#336)
Co-authored-by: thucpham <[email protected]>
1 parent 6279d86 commit 7511775

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ project(OpenNMTTokenizer)
1010
option(BUILD_TESTS "Compile unit tests" OFF)
1111
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
1212

13-
set(CMAKE_CXX_STANDARD 11)
13+
set(CMAKE_CXX_STANDARD 17)
1414
if(CMAKE_VERSION VERSION_LESS "3.7.0")
1515
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1616
endif()

src/SentencePiece.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ namespace onmt
5454
if (options && (options->joiner_annotate || options->spacer_new))
5555
throw std::invalid_argument("SentencePiece vocabulary restriction requires the tokenization "
5656
"to use \"spacer_annotate\" (same as spm_encode)");
57-
auto status = _processor->SetVocabulary(vocabulary);
57+
std::vector<std::string_view> vocabulary_views;
58+
vocabulary_views.reserve(vocabulary.size());
59+
for (const auto& s : vocabulary) {
60+
vocabulary_views.emplace_back(s);
61+
}
62+
auto status = _processor->SetVocabulary(vocabulary_views);
5863
if (!status.ok())
5964
throw std::invalid_argument(status.ToString());
6065
}

0 commit comments

Comments
 (0)