diff --git a/CMakeLists.txt b/CMakeLists.txt index 4106204..2677753 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ else () message(STATUS "Compiler is recent enough to support C++17.") endif () -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -pthread -Wall") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -pthread -Wall") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -march=native -O3") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer -O0 -g -DDEBUG") diff --git a/include/xcdat.hpp b/include/xcdat.hpp index 22a7823..de8085b 100644 --- a/include/xcdat.hpp +++ b/include/xcdat.hpp @@ -1,5 +1,8 @@ #pragma once +#include +#include + #include "xcdat/bc_vector_15.hpp" #include "xcdat/bc_vector_16.hpp" #include "xcdat/bc_vector_7.hpp" @@ -40,7 +43,7 @@ template //! Load the trie dictionary from the file. template -[[maybe_unused]] Trie load(std::string_view filepath) { +[[maybe_unused]] Trie load(const std::string& filepath) { load_visitor visitor(filepath); std::uint32_t flag; @@ -54,7 +57,7 @@ template //! Save the trie dictionary to the file and returns the file size in bytes. template -[[maybe_unused]] std::uint64_t save(const Trie& idx, std::string_view filepath) { +[[maybe_unused]] std::uint64_t save(const Trie& idx, const std::string& filepath) { save_visitor visitor(filepath); visitor.visit(static_cast(Trie::l1_bits)); // flag visitor.visit(const_cast(idx)); @@ -72,7 +75,7 @@ template //! Get the flag indicating the trie dictionary type, embedded by the function 'save'. //! The flag corresponds to trie::l1_bits and will be used to detect the trie type from the file. -[[maybe_unused]] std::uint32_t get_flag(std::string_view filepath) { +[[maybe_unused]] std::uint32_t get_flag(const std::string& filepath) { std::ifstream ifs(filepath); XCDAT_THROW_IF(!ifs.good(), "Cannot open the input file"); @@ -82,7 +85,7 @@ template } //! Load the keywords from the file. -[[maybe_unused]] std::vector load_strings(std::string_view filepath, char delim = '\n') { +[[maybe_unused]] std::vector load_strings(const std::string& filepath, char delim = '\n') { std::ifstream ifs(filepath); XCDAT_THROW_IF(!ifs.good(), "Cannot open the input file"); diff --git a/include/xcdat/load_visitor.hpp b/include/xcdat/load_visitor.hpp index bf6cf66..8c9488c 100644 --- a/include/xcdat/load_visitor.hpp +++ b/include/xcdat/load_visitor.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include "exception.hpp" @@ -13,7 +13,7 @@ class load_visitor { std::ifstream m_ifs; public: - load_visitor(std::string_view filepath) : m_ifs(filepath, std::ios::binary) { + load_visitor(const std::string& filepath) : m_ifs(filepath, std::ios::binary) { XCDAT_THROW_IF(!m_ifs.good(), "Cannot open the input file"); } diff --git a/include/xcdat/save_visitor.hpp b/include/xcdat/save_visitor.hpp index f81270b..5b0e489 100644 --- a/include/xcdat/save_visitor.hpp +++ b/include/xcdat/save_visitor.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include "exception.hpp" @@ -13,7 +13,7 @@ class save_visitor { std::ofstream m_ofs; public: - save_visitor(std::string_view filepath) : m_ofs(filepath, std::ios::binary) { + save_visitor(const std::string& filepath) : m_ofs(filepath, std::ios::binary) { XCDAT_THROW_IF(!m_ofs.good(), "Cannot open the input file"); }