Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:58:27

0001 //
0002 // Copyright (c) 2019-2025 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 
0008 #ifndef BOOST_MYSQL_FIELD_VIEW_HPP
0009 #define BOOST_MYSQL_FIELD_VIEW_HPP
0010 
0011 #include <boost/mysql/blob_view.hpp>
0012 #include <boost/mysql/date.hpp>
0013 #include <boost/mysql/datetime.hpp>
0014 #include <boost/mysql/field_kind.hpp>
0015 #include <boost/mysql/string_view.hpp>
0016 #include <boost/mysql/time.hpp>
0017 
0018 #include <boost/mysql/detail/access.hpp>
0019 #include <boost/mysql/detail/config.hpp>
0020 #include <boost/mysql/detail/field_impl.hpp>
0021 #include <boost/mysql/detail/string_view_offset.hpp>
0022 
0023 #include <boost/config.hpp>
0024 
0025 #include <cstddef>
0026 #include <cstdint>
0027 #include <iosfwd>
0028 
0029 namespace boost {
0030 namespace mysql {
0031 
0032 /**
0033  * \brief Non-owning variant-like class that can represent of any of the allowed database types.
0034  * \details
0035  * This is a variant-like class, similar to \ref field, but semi-owning and read-only. Values
0036  * of this type are usually created by the library, not directly by the user. It's cheap to
0037  * construct and copy, and it's the main library interface when reading values from MySQL.
0038  * \n
0039  * Like a variant, at any point, a `field_view` always points to a value of
0040  * certain type. You can query the type using \ref field_view::kind and the `is_xxx` functions
0041  * like \ref field_view::is_int64. Use `as_xxx` and `get_xxx` for checked and unchecked value
0042  * access, respectively. As opposed to \ref field, these functions return values instead of
0043  * references.
0044  *
0045  * \par Object lifetimes
0046  * Depending on how it was constructed, `field_view` can have value or reference semantics:
0047  * \n
0048  * \li If it was created by the library, the `field_view` will have an associated \ref row,
0049  *     \ref rows or \ref results object holding memory to which the `field_view` points. It will be valid as
0050  *     long as the memory allocated by that object is valid.
0051  * \li If it was created from a \ref field (by calling `operator field_view`), the
0052  *     `field_view` acts as a reference to that `field` object, and will be valid as long as the
0053  *     `field` is.
0054  * \li If it was created from a scalar (null, integral, floating point, date, datetime or time), the
0055  *     `field_view` has value semnatics and will always be valid.
0056  * \li If it was created from a string or blob type, the `field_view` acts as a `string_view` or `blob_view`,
0057  *     and will be valid as long as the original string/blob is.
0058  * \n
0059  * Calling any member function on a `field_view` that has been invalidated results in undefined
0060  * behavior.
0061  */
0062 class field_view
0063 {
0064 public:
0065     /**
0066      * \brief Constructs a `field_view` holding NULL.
0067      * \par Exception safety
0068      * No-throw guarantee.
0069      *
0070      * \par Object lifetimes
0071      * Results in a `field_view` with value semantics (always valid).
0072      */
0073     BOOST_CXX14_CONSTEXPR field_view() = default;
0074 
0075     /**
0076      * \brief Constructs a `field_view` holding NULL.
0077      * \details
0078      * Caution: `field_view(NULL)` will <b>not</b> match this overload. It will try to construct
0079      * a `string_view` from a NULL C string, causing undefined behavior.
0080      *
0081      * \par Exception safety
0082      * No-throw guarantee.
0083      *
0084      * \par Object lifetimes
0085      * Results in a `field_view` with value semantics (always valid).
0086      */
0087     BOOST_CXX14_CONSTEXPR explicit field_view(std::nullptr_t) noexcept {}
0088 
0089     /**
0090      * \brief Constructs a `field_view` holding an `int64`.
0091      * \par Exception safety
0092      * No-throw guarantee.
0093      *
0094      * \par Object lifetimes
0095      * Results in a `field_view` with value semantics (always valid).
0096      */
0097     BOOST_CXX14_CONSTEXPR explicit field_view(signed char v) noexcept : impl_{std::int64_t(v)} {}
0098 
0099     /// \copydoc field_view(signed char)
0100     BOOST_CXX14_CONSTEXPR explicit field_view(short v) noexcept : impl_{std::int64_t(v)} {}
0101 
0102     /// \copydoc field_view(signed char)
0103     BOOST_CXX14_CONSTEXPR explicit field_view(int v) noexcept : impl_{std::int64_t(v)} {}
0104 
0105     /// \copydoc field_view(signed char)
0106     BOOST_CXX14_CONSTEXPR explicit field_view(long v) noexcept : impl_{std::int64_t(v)} {}
0107 
0108     /// \copydoc field_view(signed char)
0109     BOOST_CXX14_CONSTEXPR explicit field_view(long long v) noexcept : impl_{std::int64_t(v)} {}
0110 
0111     /**
0112      * \brief Constructs a `field_view` holding a `uint64`.
0113      * \par Exception safety
0114      * No-throw guarantee.
0115      *
0116      * \par Object lifetimes
0117      * Results in a `field_view` with value semantics (always valid).
0118      */
0119     BOOST_CXX14_CONSTEXPR explicit field_view(unsigned char v) noexcept : impl_{std::uint64_t(v)} {}
0120 
0121     /// \copydoc field_view(unsigned char)
0122     BOOST_CXX14_CONSTEXPR explicit field_view(unsigned short v) noexcept : impl_{std::uint64_t(v)} {}
0123 
0124     /// \copydoc field_view(unsigned char)
0125     BOOST_CXX14_CONSTEXPR explicit field_view(unsigned int v) noexcept : impl_{std::uint64_t(v)} {}
0126 
0127     /// \copydoc field_view(unsigned char)
0128     BOOST_CXX14_CONSTEXPR explicit field_view(unsigned long v) noexcept : impl_{std::uint64_t(v)} {}
0129 
0130     /// \copydoc field_view(unsigned char)
0131     BOOST_CXX14_CONSTEXPR explicit field_view(unsigned long long v) noexcept : impl_{std::uint64_t(v)} {}
0132 
0133     /**
0134      * \brief Constructors from character types would incorrectly construct a `field_view` holding an integer,
0135      * so they are not allowed.
0136      */
0137     explicit field_view(char) = delete;
0138 
0139     /// \copydoc field_view(char)
0140     explicit field_view(wchar_t) = delete;
0141 
0142     /// \copydoc field_view(char)
0143     explicit field_view(char16_t) = delete;
0144 
0145     /// \copydoc field_view(char)
0146     explicit field_view(char32_t) = delete;
0147 
0148 #ifdef __cpp_char8_t
0149     /// \copydoc field_view(char)
0150     explicit field_view(char8_t) = delete;
0151 #endif
0152 
0153     /**
0154      * \brief Constructs a `field_view` holding a string.
0155      * \par Exception safety
0156      * No-throw guarantee.
0157      *
0158      * \par Object lifetimes
0159      * Results in a `field_view` with reference semantics. It will
0160      * be valid as long as the character buffer the `string_view` points to is valid.
0161      */
0162     BOOST_CXX14_CONSTEXPR explicit field_view(string_view v) noexcept : impl_{v} {}
0163 
0164     /**
0165      * \brief Constructs a `field_view` holding a blob.
0166      * \par Exception safety
0167      * No-throw guarantee.
0168      *
0169      * \par Object lifetimes
0170      * Results in a `field_view` with reference semantics. It will
0171      * be valid as long as the character buffer the `blob_view` points to is valid.
0172      */
0173     BOOST_CXX14_CONSTEXPR explicit field_view(blob_view v) noexcept : impl_{v} {}
0174 
0175     /**
0176      * \brief Constructs a `field_view` holding a `float`.
0177      * \par Exception safety
0178      * No-throw guarantee.
0179      *
0180      * \par Object lifetimes
0181      * Results in a `field_view` with value semantics (always valid).
0182      */
0183     BOOST_CXX14_CONSTEXPR explicit field_view(float v) noexcept : impl_{v} {}
0184 
0185     /**
0186      * \brief Constructs a `field_view` holding a `double`.
0187      * \par Exception safety
0188      * No-throw guarantee.
0189      *
0190      * \par Object lifetimes
0191      * Results in a `field_view` with value semantics (always valid).
0192      */
0193     BOOST_CXX14_CONSTEXPR explicit field_view(double v) noexcept : impl_{v} {}
0194 
0195     /**
0196      * \brief Constructs a `field_view` holding a `date`.
0197      * \par Exception safety
0198      * No-throw guarantee.
0199      *
0200      * \par Object lifetimes
0201      * Results in a `field_view` with value semantics (always valid).
0202      */
0203     BOOST_CXX14_CONSTEXPR explicit field_view(const date& v) noexcept : impl_{v} {}
0204 
0205     /**
0206      * \brief Constructs a `field_view` holding a `datetime`.
0207      * \par Exception safety
0208      * No-throw guarantee.
0209      *
0210      * \par Object lifetimes
0211      * Results in a `field_view` with value semantics (always valid).
0212      */
0213     BOOST_CXX14_CONSTEXPR explicit field_view(const datetime& v) noexcept : impl_{v} {}
0214 
0215     /**
0216      * \brief Constructs a `field_view` holding a `time`.
0217      * \par Exception safety
0218      * No-throw guarantee.
0219      *
0220      * \par Object lifetimes
0221      * Results in a `field_view` with value semantics (always valid).
0222      */
0223     BOOST_CXX14_CONSTEXPR explicit field_view(const time& v) noexcept : impl_{v} {}
0224 
0225     /**
0226      * \brief Returns the type of the value this `field_view` is pointing to.
0227      * \par Exception safety
0228      * No-throw guarantee.
0229      */
0230     BOOST_CXX14_CONSTEXPR inline field_kind kind() const noexcept;
0231 
0232     /**
0233      * \brief Returns whether this `field_view` points to a `NULL` value.
0234      * \par Exception safety
0235      * No-throw guarantee.
0236      */
0237     BOOST_CXX14_CONSTEXPR bool is_null() const noexcept { return kind() == field_kind::null; }
0238 
0239     /**
0240      * \brief Returns whether this `field_view` points to a `int64` value.
0241      * \par Exception safety
0242      * No-throw guarantee.
0243      */
0244     BOOST_CXX14_CONSTEXPR bool is_int64() const noexcept { return kind() == field_kind::int64; }
0245 
0246     /**
0247      * \brief Returns whether this `field_view` points to a `uint64` value.
0248      * \par Exception safety
0249      * No-throw guarantee.
0250      */
0251     BOOST_CXX14_CONSTEXPR bool is_uint64() const noexcept { return kind() == field_kind::uint64; }
0252 
0253     /**
0254      * \brief Returns whether this `field_view` points to a string value.
0255      * \par Exception safety
0256      * No-throw guarantee.
0257      */
0258     BOOST_CXX14_CONSTEXPR bool is_string() const noexcept { return kind() == field_kind::string; }
0259 
0260     /**
0261      * \brief Returns whether this `field_view` points to a binary blob.
0262      * \par Exception safety
0263      * No-throw guarantee.
0264      */
0265     BOOST_CXX14_CONSTEXPR bool is_blob() const noexcept { return kind() == field_kind::blob; }
0266 
0267     /**
0268      * \brief Returns whether this `field_view` points to a `float` value.
0269      * \par Exception safety
0270      * No-throw guarantee.
0271      */
0272     BOOST_CXX14_CONSTEXPR bool is_float() const noexcept { return kind() == field_kind::float_; }
0273 
0274     /**
0275      * \brief Returns whether this `field_view` points to a `double` value.
0276      * \par Exception safety
0277      * No-throw guarantee.
0278      */
0279     BOOST_CXX14_CONSTEXPR bool is_double() const noexcept { return kind() == field_kind::double_; }
0280 
0281     /**
0282      * \brief Returns whether this `field_view` points to a `date` value.
0283      * \par Exception safety
0284      * No-throw guarantee.
0285      */
0286     BOOST_CXX14_CONSTEXPR bool is_date() const noexcept { return kind() == field_kind::date; }
0287 
0288     /**
0289      * \brief Returns whether this `field_view` points to a `datetime` value.
0290      * \par Exception safety
0291      * No-throw guarantee.
0292      */
0293     BOOST_CXX14_CONSTEXPR bool is_datetime() const noexcept { return kind() == field_kind::datetime; }
0294 
0295     /**
0296      * \brief Returns whether this `field_view` points to a `time` value.
0297      * \par Exception safety
0298      * No-throw guarantee.
0299      */
0300     BOOST_CXX14_CONSTEXPR bool is_time() const noexcept { return kind() == field_kind::time; }
0301 
0302     /**
0303      * \brief Retrieves the underlying value as an `int64` or throws an exception.
0304      * \par Exception safety
0305      * Strong guarantee. Throws on type mismatch.
0306      * \throws bad_field_access If `!this->is_int64()`
0307      */
0308     BOOST_CXX14_CONSTEXPR inline std::int64_t as_int64() const;
0309 
0310     /**
0311      * \brief Retrieves the underlying value as an `uint64` or throws an exception.
0312      * \par Exception safety
0313      * Strong guarantee. Throws on type mismatch.
0314      * \throws bad_field_access If `!this->is_uint64()`
0315      */
0316     BOOST_CXX14_CONSTEXPR inline std::uint64_t as_uint64() const;
0317 
0318     /**
0319      * \brief Retrieves the underlying value as a string or throws an exception.
0320      * \par Exception safety
0321      * Strong guarantee. Throws on type mismatch.
0322      * \throws bad_field_access If `!this->is_string()`
0323      * \par Object lifetimes
0324      * The returned view has the same lifetime rules as `*this` (it's valid as long as `*this` is valid).
0325      */
0326     BOOST_CXX14_CONSTEXPR inline string_view as_string() const;
0327 
0328     /**
0329      * \brief Retrieves the underlying value as a blob or throws an exception.
0330      * \par Exception safety
0331      * Strong guarantee. Throws on type mismatch.
0332      * \throws bad_field_access If `!this->is_blob()`
0333      * \par Object lifetimes
0334      * The returned view has the same lifetime rules as `*this` (it's valid as long as `*this` is valid).
0335      */
0336     BOOST_CXX14_CONSTEXPR inline blob_view as_blob() const;
0337 
0338     /**
0339      * \brief Retrieves the underlying value as a `float` or throws an exception.
0340      * \par Exception safety
0341      * Strong guarantee. Throws on type mismatch.
0342      * \throws bad_field_access If `!this->is_float()`
0343      */
0344     BOOST_CXX14_CONSTEXPR inline float as_float() const;
0345 
0346     /**
0347      * \brief Retrieves the underlying value as a `double` or throws an exception.
0348      * \par Exception safety
0349      * Strong guarantee. Throws on type mismatch.
0350      * \throws bad_field_access If `!this->is_double()`
0351      */
0352     BOOST_CXX14_CONSTEXPR inline double as_double() const;
0353 
0354     /**
0355      * \brief Retrieves the underlying value as a `date` or throws an exception.
0356      * \par Exception safety
0357      * Strong guarantee. Throws on type mismatch.
0358      * \throws bad_field_access If `!this->is_date()`
0359      */
0360     BOOST_CXX14_CONSTEXPR inline date as_date() const;
0361 
0362     /**
0363      * \brief Retrieves the underlying value as a `datetime` or throws an exception.
0364      * \par Exception safety
0365      * Strong guarantee. Throws on type mismatch.
0366      * \throws bad_field_access If `!this->is_datetime()`
0367      */
0368     BOOST_CXX14_CONSTEXPR inline datetime as_datetime() const;
0369 
0370     /**
0371      * \brief Retrieves the underlying value as a `time` or throws an exception.
0372      * \par Exception safety
0373      * Strong guarantee. Throws on type mismatch.
0374      * \throws bad_field_access If `!this->is_time()`
0375      */
0376     BOOST_CXX14_CONSTEXPR inline time as_time() const;
0377 
0378     /**
0379      * \brief Retrieves the underlying value as an `int64` (unchecked access).
0380      * \par Preconditions
0381      * `this->is_int64() == true` (if violated, results in undefined behavior).
0382      *
0383      * \par Exception safety
0384      * No-throw guarantee.
0385      */
0386     BOOST_CXX14_CONSTEXPR inline std::int64_t get_int64() const noexcept
0387     {
0388         return is_field_ptr() ? impl_.repr.field_ptr->get<std::int64_t>() : impl_.repr.int64;
0389     }
0390 
0391     /**
0392      * \brief Retrieves the underlying value as an `uint64` (unchecked access).
0393      * \par Preconditions
0394      * `this->is_uint64() == true` (if violated, results in undefined behavior).
0395      *
0396      * \par Exception safety
0397      * No-throw guarantee.
0398      */
0399     BOOST_CXX14_CONSTEXPR inline std::uint64_t get_uint64() const noexcept
0400     {
0401         return is_field_ptr() ? impl_.repr.field_ptr->get<std::uint64_t>() : impl_.repr.uint64;
0402     }
0403 
0404     /**
0405      * \brief Retrieves the underlying value as a string (unchecked access).
0406      * \par Preconditions
0407      * `this->is_string() == true` (if violated, results in undefined behavior).
0408      *
0409      * \par Exception safety
0410      * No-throw guarantee.
0411      *
0412      * \par Object lifetimes
0413      * The returned view has the same lifetime rules as `*this` (it's valid as long as `*this` is valid).
0414      */
0415     BOOST_CXX14_CONSTEXPR inline string_view get_string() const noexcept
0416     {
0417         return is_field_ptr() ? string_view(impl_.repr.field_ptr->get<std::string>()) : impl_.repr.string;
0418     }
0419 
0420     /**
0421      * \brief Retrieves the underlying value as a blob (unchecked access).
0422      * \par Preconditions
0423      * `this->is_blob() == true` (if violated, results in undefined behavior).
0424      *
0425      * \par Exception safety
0426      * No-throw guarantee.
0427      *
0428      * \par Object lifetimes
0429      * The returned view has the same lifetime rules as `*this` (it's valid as long as `*this` is valid).
0430      */
0431     BOOST_CXX14_CONSTEXPR inline blob_view get_blob() const noexcept
0432     {
0433         return is_field_ptr() ? impl_.repr.field_ptr->get<blob>() : impl_.repr.blob;
0434     }
0435 
0436     /**
0437      * \brief Retrieves the underlying value as a `float` (unchecked access).
0438      * \par Preconditions
0439      * `this->is_float() == true` (if violated, results in undefined behavior).
0440      *
0441      * \par Exception safety
0442      * No-throw guarantee.
0443      */
0444     BOOST_CXX14_CONSTEXPR inline float get_float() const noexcept
0445     {
0446         return is_field_ptr() ? impl_.repr.field_ptr->get<float>() : impl_.repr.float_;
0447     }
0448 
0449     /**
0450      * \brief Retrieves the underlying value as a `double` (unchecked access).
0451      * \par Preconditions
0452      * `this->is_double() == true` (if violated, results in undefined behavior).
0453      *
0454      * \par Exception safety
0455      * No-throw guarantee.
0456      */
0457     BOOST_CXX14_CONSTEXPR inline double get_double() const noexcept
0458     {
0459         return is_field_ptr() ? impl_.repr.field_ptr->get<double>() : impl_.repr.double_;
0460     }
0461 
0462     /**
0463      * \brief Retrieves the underlying value as a `date` (unchecked access).
0464      * \par Preconditions
0465      * `this->is_date() == true` (if violated, results in undefined behavior).
0466      *
0467      * \par Exception safety
0468      * No-throw guarantee.
0469      */
0470     BOOST_CXX14_CONSTEXPR inline date get_date() const noexcept
0471     {
0472         return is_field_ptr() ? impl_.repr.field_ptr->get<date>() : impl_.repr.date_;
0473     }
0474 
0475     /**
0476      * \brief Retrieves the underlying value as a `datetime` (unchecked access).
0477      * \par Preconditions
0478      * `this->is_datetime() == true` (if violated, results in undefined behavior).
0479      *
0480      * \par Exception safety
0481      * No-throw guarantee.
0482      */
0483     BOOST_CXX14_CONSTEXPR inline datetime get_datetime() const noexcept
0484     {
0485         return is_field_ptr() ? impl_.repr.field_ptr->get<datetime>() : impl_.repr.datetime_;
0486     }
0487 
0488     /**
0489      * \brief Retrieves the underlying value as a `time` (unchecked access).
0490      * \par Preconditions
0491      * `this->is_time() == true` (if violated, results in undefined behavior).
0492      *
0493      * \par Exception safety
0494      * No-throw guarantee.
0495      */
0496     BOOST_CXX14_CONSTEXPR inline time get_time() const noexcept
0497     {
0498         return is_field_ptr() ? impl_.repr.field_ptr->get<time>() : impl_.repr.time_;
0499     }
0500 
0501     /**
0502      * \brief Tests for equality.
0503      * \details
0504      * If one of the operands is a `uint64` and the other a
0505      * `int64`, and the values are equal, returns `true`. Otherwise, if the types are
0506      * different, returns always `false` (`float` and `double` values are considered to be
0507      * different between them). `NULL` values are equal to other `NULL` values.
0508      *
0509      * \par Exception safety
0510      * No-throw guarantee.
0511      */
0512     BOOST_CXX14_CONSTEXPR inline bool operator==(const field_view& rhs) const noexcept;
0513 
0514     /**
0515      * \brief Tests for inequality.
0516      * \par Exception safety
0517      * No-throw guarantee.
0518      */
0519     BOOST_CXX14_CONSTEXPR bool operator!=(const field_view& rhs) const noexcept { return !(*this == rhs); }
0520 
0521 private:
0522     BOOST_CXX14_CONSTEXPR explicit field_view(detail::string_view_offset v, bool is_blob) noexcept
0523         : impl_{v, is_blob}
0524     {
0525     }
0526 
0527     BOOST_CXX14_CONSTEXPR explicit field_view(const detail::field_impl* v) noexcept : impl_{v} {}
0528 
0529     enum class internal_kind
0530     {
0531         null = 0,
0532         int64,
0533         uint64,
0534         string,
0535         blob,
0536         float_,
0537         double_,
0538         date,
0539         datetime,
0540         time,
0541         sv_offset_string,
0542         sv_offset_blob,
0543         field_ptr
0544     };
0545 
0546     union repr_t
0547     {
0548         std::int64_t int64;
0549         std::uint64_t uint64;
0550         string_view string;
0551         blob_view blob;
0552         float float_;
0553         double double_;
0554         date date_;
0555         datetime datetime_;
0556         time time_;
0557         detail::string_view_offset sv_offset_;
0558         const detail::field_impl* field_ptr;
0559 
0560         BOOST_CXX14_CONSTEXPR repr_t() noexcept : int64{} {}
0561         BOOST_CXX14_CONSTEXPR repr_t(std::int64_t v) noexcept : int64(v) {}
0562         BOOST_CXX14_CONSTEXPR repr_t(std::uint64_t v) noexcept : uint64(v) {}
0563         BOOST_CXX14_CONSTEXPR repr_t(string_view v) noexcept : string{v} {}
0564         BOOST_CXX14_CONSTEXPR repr_t(blob_view v) noexcept : blob{v} {}
0565         BOOST_CXX14_CONSTEXPR repr_t(float v) noexcept : float_(v) {}
0566         BOOST_CXX14_CONSTEXPR repr_t(double v) noexcept : double_(v) {}
0567         BOOST_CXX14_CONSTEXPR repr_t(date v) noexcept : date_(v) {}
0568         BOOST_CXX14_CONSTEXPR repr_t(datetime v) noexcept : datetime_(v) {}
0569         BOOST_CXX14_CONSTEXPR repr_t(time v) noexcept : time_(v) {}
0570         BOOST_CXX14_CONSTEXPR repr_t(detail::string_view_offset v) noexcept : sv_offset_(v) {}
0571         BOOST_CXX14_CONSTEXPR repr_t(const detail::field_impl* v) noexcept : field_ptr(v) {}
0572     };
0573 
0574     struct impl_t
0575     {
0576         internal_kind ikind{internal_kind::null};
0577         repr_t repr{};
0578 
0579         // Required by lib internal functions
0580         bool is_string_offset() const noexcept { return ikind == internal_kind::sv_offset_string; }
0581         bool is_blob_offset() const noexcept { return ikind == internal_kind::sv_offset_blob; }
0582 
0583         BOOST_CXX14_CONSTEXPR impl_t() = default;
0584         BOOST_CXX14_CONSTEXPR impl_t(std::int64_t v) noexcept : ikind(internal_kind::int64), repr(v) {}
0585         BOOST_CXX14_CONSTEXPR impl_t(std::uint64_t v) noexcept : ikind(internal_kind::uint64), repr(v) {}
0586         BOOST_CXX14_CONSTEXPR impl_t(string_view v) noexcept : ikind(internal_kind::string), repr{v} {}
0587         BOOST_CXX14_CONSTEXPR impl_t(blob_view v) noexcept : ikind(internal_kind::blob), repr{v} {}
0588         BOOST_CXX14_CONSTEXPR impl_t(float v) noexcept : ikind(internal_kind::float_), repr(v) {}
0589         BOOST_CXX14_CONSTEXPR impl_t(double v) noexcept : ikind(internal_kind::double_), repr(v) {}
0590         BOOST_CXX14_CONSTEXPR impl_t(date v) noexcept : ikind(internal_kind::date), repr(v) {}
0591         BOOST_CXX14_CONSTEXPR impl_t(datetime v) noexcept : ikind(internal_kind::datetime), repr(v) {}
0592         BOOST_CXX14_CONSTEXPR impl_t(time v) noexcept : ikind(internal_kind::time), repr(v) {}
0593         BOOST_CXX14_CONSTEXPR impl_t(detail::string_view_offset v, bool is_blob) noexcept
0594             : ikind(is_blob ? internal_kind::sv_offset_blob : internal_kind::sv_offset_string), repr{v}
0595         {
0596         }
0597         BOOST_CXX14_CONSTEXPR impl_t(const detail::field_impl* v) noexcept
0598             : ikind(internal_kind::field_ptr), repr(v)
0599         {
0600         }
0601     } impl_;
0602 
0603     BOOST_CXX14_CONSTEXPR bool is_field_ptr() const noexcept
0604     {
0605         return impl_.ikind == internal_kind::field_ptr;
0606     }
0607     BOOST_CXX14_CONSTEXPR inline void check_kind(internal_kind expected) const;
0608 
0609 #ifndef BOOST_MYSQL_DOXYGEN
0610     friend class field;
0611     friend struct detail::access;
0612     BOOST_MYSQL_DECL
0613     friend std::ostream& operator<<(std::ostream& os, const field_view& v);
0614 #endif
0615 };
0616 
0617 /**
0618  * \relates field_view
0619  * \brief Streams a `field_view`.
0620  */
0621 BOOST_MYSQL_DECL
0622 std::ostream& operator<<(std::ostream& os, const field_view& v);
0623 
0624 }  // namespace mysql
0625 }  // namespace boost
0626 
0627 #include <boost/mysql/impl/field_view.hpp>
0628 #ifdef BOOST_MYSQL_HEADER_ONLY
0629 #include <boost/mysql/impl/field_view.ipp>
0630 #endif
0631 
0632 #endif