Skip to content

Commit

Permalink
Cosmetic.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtv committed May 16, 2020
1 parent 2a020fe commit b39ae42
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
6 changes: 4 additions & 2 deletions include/pqxx/internal/conversions.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ template<typename... T> struct nullness<std::variant<T...>>
static constexpr bool is_null(std::variant<T...> const &value) noexcept
{
return std::visit(
[](auto const &i) { return nullness<strip_t<decltype(i)>>::is_null(i); },
[](auto const &i) noexcept {
return nullness<strip_t<decltype(i)>>::is_null(i);
},
value);
}

Expand Down Expand Up @@ -517,7 +519,7 @@ template<> struct nullness<std::nullptr_t>
{
return true;
}
static constexpr std::nullptr_t null() { return nullptr; }
static constexpr std::nullptr_t null() noexcept { return nullptr; }
};


Expand Down
18 changes: 3 additions & 15 deletions include/pqxx/strconv.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -303,22 +303,10 @@ inline void into_string(TYPE const &value, std::string &out);


/// Is @c value null?
template<typename TYPE>[[nodiscard]] inline bool is_null(TYPE const &value)
template<typename TYPE>
[[nodiscard]] inline bool is_null(TYPE const &value) noexcept
{
if constexpr (nullness<TYPE>::always_null)
{
ignore_unused(value);
return true;
}
else if constexpr (nullness<TYPE>::has_null)
{
return nullness<TYPE>::is_null(value);
}
else
{
ignore_unused(value);
return false;
}
return nullness<TYPE>::is_null(value);
}


Expand Down
7 changes: 4 additions & 3 deletions include/pqxx/stream_from.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,17 @@ template<typename Tuple, std::size_t index>
inline void stream_from::extract_value(Tuple &t) const
{
using field_type = strip_t<decltype(std::get<index>(t))>;
using nullity = nullness<field_type>;
assert(index < m_fields.size());
if constexpr (nullness<field_type>::always_null)
if constexpr (nullity::always_null)
{
if (m_fields[index].data() != nullptr)
throw conversion_error{"Streaming non-null value into null field."};
}
else if (m_fields[index].data() == nullptr)
{
if constexpr (nullness<field_type>::has_null)
std::get<index>(t) = nullness<field_type>::null();
if constexpr (nullity::has_null)
std::get<index>(t) = nullity::null();
else
internal::throw_null_conversion(type_name<field_type>);
}
Expand Down

0 comments on commit b39ae42

Please sign in to comment.