Skip to content

Commit 0212014

Browse files
committed
Correct the code #265
1 parent 9af2821 commit 0212014

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

library/lattice/test/src/test_tetengo.lattice.custom_vocabulary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ BOOST_AUTO_TEST_CASE(find_entries)
123123
BOOST_TEST_REQUIRE(entry_count == 2U);
124124

125125
std::vector<tetengo_lattice_entryView_t> entries(entry_count);
126-
const auto entry_count_again = tetengo_lattice_vocabulary_findEntries(p_vocabulary, p_input, entries.data());
126+
const auto entry_count_again = tetengo_lattice_vocabulary_findEntries(p_vocabulary, p_input, std::data(entries));
127127
BOOST_TEST(entry_count_again == entry_count);
128128
const auto* const p_entry_key0 = tetengo_lattice_entryView_createKeyOf(entries[0].key_handle);
129129
BOOST_SCOPE_EXIT(p_entry_key0)

library/text/cpp/src/tetengo.text.encoding.utf8.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Copyright (C) 2019-2022 kaoru https://www.tetengo.org/
55
*/
66

7+
#include <iterator>
78
#include <memory>
89

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

4142
encoded_string_type encode(const string_view_type& utf8) const
4243
{
43-
return encoded_string_type{ reinterpret_cast<const encoded_string_type::value_type*>(utf8.data()),
44+
return encoded_string_type{ reinterpret_cast<const encoded_string_type::value_type*>(std::data(utf8)),
4445
utf8.length() };
4546
}
4647

4748
string_type decode(const encoded_string_view_type& string_) const
4849
{
49-
return string_type{ reinterpret_cast<const string_type::value_type*>(string_.data()), string_.length() };
50+
return string_type{ reinterpret_cast<const string_type::value_type*>(std::data(string_)),
51+
string_.length() };
5052
}
5153
};
5254

sample/make_dict/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace
5454
else
5555
{
5656
const auto encoded = tetengo::text::encoder<tetengo::text::encoding::utf8>::instance().encode(string_);
57-
return std::string{ reinterpret_cast<const char*>(encoded.data()), encoded.length() };
57+
return std::string{ reinterpret_cast<const char*>(std::data(encoded)), encoded.length() };
5858
}
5959
}
6060

sample/search_dict/src/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ namespace
4343
}
4444
else
4545
{
46-
const std::u8string_view utf8_encoded{ reinterpret_cast<const char8_t*>(encoded.data()), encoded.length() };
46+
const std::u8string_view utf8_encoded{ reinterpret_cast<const char8_t*>(std::data(encoded)),
47+
encoded.length() };
4748
return std::string{ tetengo::text::encoder<tetengo::text::encoding::utf8>::instance().decode(
4849
utf8_encoded) };
4950
}
@@ -59,7 +60,7 @@ namespace
5960
else
6061
{
6162
const auto encoded = tetengo::text::encoder<tetengo::text::encoding::utf8>::instance().encode(string_);
62-
return std::string{ reinterpret_cast<const char*>(encoded.data()), encoded.length() };
63+
return std::string{ reinterpret_cast<const char*>(std::data(encoded)), encoded.length() };
6364
}
6465
}
6566

sample/transfer_trains/src/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ namespace
5757
}
5858
else
5959
{
60-
const std::u8string_view utf8_encoded{ reinterpret_cast<const char8_t*>(encoded.data()), encoded.length() };
60+
const std::u8string_view utf8_encoded{ reinterpret_cast<const char8_t*>(std::data(encoded)),
61+
encoded.length() };
6162
return std::string{ tetengo::text::encoder<tetengo::text::encoding::utf8>::instance().decode(
6263
utf8_encoded) };
6364
}
@@ -73,7 +74,7 @@ namespace
7374
else
7475
{
7576
const auto encoded = tetengo::text::encoder<tetengo::text::encoding::utf8>::instance().encode(string_);
76-
return std::string{ reinterpret_cast<const char*>(encoded.data()), encoded.length() };
77+
return std::string{ reinterpret_cast<const char*>(std::data(encoded)), encoded.length() };
7778
}
7879
}
7980

0 commit comments

Comments
 (0)