Skip to content

Commit 5e57386

Browse files
committed
Assign nullptr to the smart pointers #203
1 parent 025079e commit 5e57386

File tree

9 files changed

+13
-17
lines changed

9 files changed

+13
-17
lines changed

library/json/test/src/test_tetengo.json.json_parser.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ BOOST_AUTO_TEST_CASE(construction)
152152
const tetengo::json::json_parser parser{ std::move(p_reader), 42 };
153153
}
154154
{
155-
BOOST_CHECK_THROW(
156-
const tetengo::json::json_parser parser{ std::unique_ptr<tetengo::json::reader>{} }, std::invalid_argument);
155+
BOOST_CHECK_THROW(const tetengo::json::json_parser parser{ nullptr }, std::invalid_argument);
157156
}
158157

159158
{

library/lattice/c/src/tetengo_lattice_vocabulary.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ tetengo_lattice_vocabulary_t* tetengo_lattice_vocabulary_createUnorderedMapVocab
7878
BOOST_SCOPE_EXIT_END;
7979
std::any cpp_entry_value{ entry.p_value };
8080
cpp_entry_values.emplace_back(
81-
p_cpp_entry_key ? p_cpp_entry_key->cpp_input().clone() : std::unique_ptr<tetengo::lattice::input>{},
81+
p_cpp_entry_key ? p_cpp_entry_key->cpp_input().clone() : nullptr,
8282
std::move(cpp_entry_value),
8383
entry.cost);
8484
}
@@ -107,12 +107,10 @@ tetengo_lattice_vocabulary_t* tetengo_lattice_vocabulary_createUnorderedMapVocab
107107
BOOST_SCOPE_EXIT_END;
108108
std::any cpp_to_value{ connection_element.p_to->p_value };
109109
auto cpp_key = std::make_pair(
110-
tetengo::lattice::entry{ p_cpp_from_key ? p_cpp_from_key->cpp_input().clone() :
111-
std::unique_ptr<tetengo::lattice::input>{},
110+
tetengo::lattice::entry{ p_cpp_from_key ? p_cpp_from_key->cpp_input().clone() : nullptr,
112111
std::move(cpp_from_value),
113112
connection_element.p_from->cost },
114-
tetengo::lattice::entry{ p_cpp_to_key ? p_cpp_to_key->cpp_input().clone() :
115-
std::unique_ptr<tetengo::lattice::input>{},
113+
tetengo::lattice::entry{ p_cpp_to_key ? p_cpp_to_key->cpp_input().clone() : nullptr,
116114
std::move(cpp_to_value),
117115
connection_element.p_to->cost });
118116

library/lattice/cpp/src/tetengo.lattice.entry.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace tetengo::lattice
1616
{
1717
const entry& entry::bos_eos()
1818
{
19-
static const entry singleton{ std::unique_ptr<input>{}, std::any{}, 0 };
19+
static const entry singleton{ nullptr, std::any{}, 0 };
2020
return singleton;
2121
}
2222

@@ -27,13 +27,13 @@ namespace tetengo::lattice
2727
{}
2828

2929
entry::entry(const entry_view& view) :
30-
m_p_key{ view.p_key() ? view.p_key()->clone() : std::unique_ptr<input>{} },
30+
m_p_key{ view.p_key() ? view.p_key()->clone() : nullptr },
3131
m_value{ *view.value() },
3232
m_cost{ view.cost() }
3333
{}
3434

3535
entry::entry(const entry& another) :
36-
m_p_key{ another.m_p_key ? another.m_p_key->clone() : std::unique_ptr<tetengo::lattice::input>{} },
36+
m_p_key{ another.m_p_key ? another.m_p_key->clone() : nullptr },
3737
m_value{ another.m_value },
3838
m_cost{ another.m_cost }
3939
{}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ BOOST_AUTO_TEST_CASE(append)
193193
concrete_input input_{};
194194

195195
input_.append(std::make_unique<concrete_input>());
196-
BOOST_CHECK_THROW(input_.append(std::unique_ptr<concrete_input>{}), std::invalid_argument);
196+
BOOST_CHECK_THROW(input_.append(nullptr), std::invalid_argument);
197197
BOOST_CHECK_THROW(input_.append(std::make_unique<concrete_input2>()), std::invalid_argument);
198198
}
199199

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ BOOST_AUTO_TEST_CASE(append)
513513
{
514514
tetengo::lattice::string_input input{ "hoge" };
515515

516-
BOOST_CHECK_THROW(input.append(std::unique_ptr<tetengo::lattice::string_input>{}), std::invalid_argument);
516+
BOOST_CHECK_THROW(input.append(nullptr), std::invalid_argument);
517517
BOOST_CHECK_THROW(input.append(std::make_unique<another_input>()), std::invalid_argument);
518518
}
519519

library/trie/c/src/tetengo_trie_storage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ namespace
112112
}
113113
catch (const boost::interprocess::interprocess_exception&)
114114
{
115-
return std::unique_ptr<boost::interprocess::file_mapping>{};
115+
return nullptr;
116116
}
117117
}
118118

library/trie/cpp/include/tetengo/trie/trie.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ namespace tetengo::trie
468468
}();
469469
if (!p_trie_impl)
470470
{
471-
return std::unique_ptr<trie>{};
471+
return nullptr;
472472
}
473473
std::unique_ptr<trie> p_trie{ new trie{ std::move(p_trie_impl), m_key_serializer } };
474474
return p_trie;

library/trie/cpp/src/tetengo.trie.double_array.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ namespace tetengo::trie
112112
std::unique_ptr<double_array> subtrie(const std::string_view& key_prefix) const
113113
{
114114
const auto o_index = traverse(key_prefix);
115-
return o_index ? std::make_unique<double_array>(m_p_storage->clone(), *o_index) :
116-
std::unique_ptr<double_array>{};
115+
return o_index ? std::make_unique<double_array>(m_p_storage->clone(), *o_index) : nullptr;
117116
}
118117

119118
const storage& get_storage() const

library/trie/cpp/src/tetengo.trie.trie.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ namespace tetengo::trie
139139
auto p_subtrie = m_p_double_array->subtrie(key_prefix);
140140
if (!p_subtrie)
141141
{
142-
return std::unique_ptr<trie_impl>{};
142+
return nullptr;
143143
}
144144
return std::make_unique<trie_impl>(std::move(p_subtrie));
145145
}

0 commit comments

Comments
 (0)