libpqxx  7.9.0
pqxx::no_null< TYPE > Struct Template Reference

Nullness traits describing a type which does not have a null value. More...

#include <strconv.hxx>

Inheritance diagram for pqxx::no_null< TYPE >:

Static Public Member Functions

static constexpr bool is_null (TYPE const &) noexcept
 Does a given value correspond to an SQL null value? More...
 

Static Public Attributes

static constexpr bool has_null = false
 Does TYPE have a "built-in null value"? More...
 
static constexpr bool always_null = false
 Are all values of this type null? More...
 

Detailed Description

template<typename TYPE>
struct pqxx::no_null< TYPE >

Nullness traits describing a type which does not have a null value.

Member Function Documentation

◆ is_null()

template<typename TYPE >
static constexpr bool pqxx::no_null< TYPE >::is_null ( TYPE const &  )
staticconstexprnoexcept

Does a given value correspond to an SQL null value?

Most C++ types, such as int or std::string, have no inherent null value. But some types such as C-style string pointers do have a natural equivalent to an SQL null.

Member Data Documentation

◆ always_null

template<typename TYPE >
constexpr bool pqxx::no_null< TYPE >::always_null = false
staticconstexpr

Are all values of this type null?

There are a few special C++ types which are always null - mainly std::nullptr_t.

◆ has_null

template<typename TYPE >
constexpr bool pqxx::no_null< TYPE >::has_null = false
staticconstexpr

Does TYPE have a "built-in null value"?

For example, a pointer can equal nullptr, which makes a very natural representation of an SQL null value. For such types, the code sometimes needs to make special allowances.

for most types, such as int or std::string, there is no built-in null. If you want to represent an SQL null value for such a type, you would have to wrap it in something that does have a null value. For example, you could use std::optional<int> for "either an @c int or a null value."


The documentation for this struct was generated from the following file: