Skip to content

Commit

Permalink
Correct the code #265
Browse files Browse the repository at this point in the history
  • Loading branch information
kaorut committed Nov 3, 2022
1 parent 9af2821 commit 0212014
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ BOOST_AUTO_TEST_CASE(find_entries)
BOOST_TEST_REQUIRE(entry_count == 2U);

std::vector<tetengo_lattice_entryView_t> entries(entry_count);
const auto entry_count_again = tetengo_lattice_vocabulary_findEntries(p_vocabulary, p_input, entries.data());
const auto entry_count_again = tetengo_lattice_vocabulary_findEntries(p_vocabulary, p_input, std::data(entries));
BOOST_TEST(entry_count_again == entry_count);
const auto* const p_entry_key0 = tetengo_lattice_entryView_createKeyOf(entries[0].key_handle);
BOOST_SCOPE_EXIT(p_entry_key0)
Expand Down
6 changes: 4 additions & 2 deletions library/text/cpp/src/tetengo.text.encoding.utf8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Copyright (C) 2019-2022 kaoru https://www.tetengo.org/
*/

#include <iterator>
#include <memory>

#include <boost/core/noncopyable.hpp>
Expand Down Expand Up @@ -40,13 +41,14 @@ namespace tetengo::text::encoding

encoded_string_type encode(const string_view_type& utf8) const
{
return encoded_string_type{ reinterpret_cast<const encoded_string_type::value_type*>(utf8.data()),
return encoded_string_type{ reinterpret_cast<const encoded_string_type::value_type*>(std::data(utf8)),
utf8.length() };
}

string_type decode(const encoded_string_view_type& string_) const
{
return string_type{ reinterpret_cast<const string_type::value_type*>(string_.data()), string_.length() };
return string_type{ reinterpret_cast<const string_type::value_type*>(std::data(string_)),
string_.length() };
}
};

Expand Down
2 changes: 1 addition & 1 deletion sample/make_dict/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace
else
{
const auto encoded = tetengo::text::encoder<tetengo::text::encoding::utf8>::instance().encode(string_);
return std::string{ reinterpret_cast<const char*>(encoded.data()), encoded.length() };
return std::string{ reinterpret_cast<const char*>(std::data(encoded)), encoded.length() };
}
}

Expand Down
5 changes: 3 additions & 2 deletions sample/search_dict/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ namespace
}
else
{
const std::u8string_view utf8_encoded{ reinterpret_cast<const char8_t*>(encoded.data()), encoded.length() };
const std::u8string_view utf8_encoded{ reinterpret_cast<const char8_t*>(std::data(encoded)),
encoded.length() };
return std::string{ tetengo::text::encoder<tetengo::text::encoding::utf8>::instance().decode(
utf8_encoded) };
}
Expand All @@ -59,7 +60,7 @@ namespace
else
{
const auto encoded = tetengo::text::encoder<tetengo::text::encoding::utf8>::instance().encode(string_);
return std::string{ reinterpret_cast<const char*>(encoded.data()), encoded.length() };
return std::string{ reinterpret_cast<const char*>(std::data(encoded)), encoded.length() };
}
}

Expand Down
5 changes: 3 additions & 2 deletions sample/transfer_trains/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ namespace
}
else
{
const std::u8string_view utf8_encoded{ reinterpret_cast<const char8_t*>(encoded.data()), encoded.length() };
const std::u8string_view utf8_encoded{ reinterpret_cast<const char8_t*>(std::data(encoded)),
encoded.length() };
return std::string{ tetengo::text::encoder<tetengo::text::encoding::utf8>::instance().decode(
utf8_encoded) };
}
Expand All @@ -73,7 +74,7 @@ namespace
else
{
const auto encoded = tetengo::text::encoder<tetengo::text::encoding::utf8>::instance().encode(string_);
return std::string{ reinterpret_cast<const char*>(encoded.data()), encoded.length() };
return std::string{ reinterpret_cast<const char*>(std::data(encoded)), encoded.length() };
}
}

Expand Down

0 comments on commit 0212014

Please sign in to comment.