libpqxx
The C++ client library for PostgreSQL
pqxx::internal::disallowed_ambiguous_char_conversion< CHAR_TYPE > Struct Template Reference

Deliberately nonfunctional conversion traits for char types. More...

#include <conversions.hxx>

Static Public Member Functions

static constexpr std::size_t size_buffer (CHAR_TYPE const &) noexcept=delete
 
static constexpr std::string_view to_buf (std::span< char >, CHAR_TYPE const &, ctx={}) noexcept=delete
 
static CHAR_TYPE from_string (std::string_view, ctx={})=delete
 

Detailed Description

template<pqxx::internal::char_type CHAR_TYPE>
struct pqxx::internal::disallowed_ambiguous_char_conversion< CHAR_TYPE >

Deliberately nonfunctional conversion traits for char types.

There are no string conversions for char and its signed and unsigned variants. Such a conversion would be dangerously ambiguous: should we treat it as text, or as a small integer? It'd be an open invitation for bugs.

But the error message when you get this wrong is very cryptic. So, we derive dummy string_traits implementations from this dummy type, and ensure that the compiler disallows their use. The compiler error message will at least contain a hint of the root of the problem.

Member Function Documentation

◆ from_string()

template<pqxx::internal::char_type CHAR_TYPE>
static CHAR_TYPE pqxx::internal::disallowed_ambiguous_char_conversion< CHAR_TYPE >::from_string ( std::string_view  ,
ctx  = {} 
)
staticdelete

◆ size_buffer()

template<pqxx::internal::char_type CHAR_TYPE>
static constexpr std::size_t pqxx::internal::disallowed_ambiguous_char_conversion< CHAR_TYPE >::size_buffer ( CHAR_TYPE const &  )
staticconstexprdeletenoexcept

◆ to_buf()

template<pqxx::internal::char_type CHAR_TYPE>
static constexpr std::string_view pqxx::internal::disallowed_ambiguous_char_conversion< CHAR_TYPE >::to_buf ( std::span< char >  ,
CHAR_TYPE const &  ,
ctx  = {} 
)
staticconstexprdeletenoexcept

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