xtd
1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
xtd.core
include
xtd
value_type.hpp
Go to the documentation of this file.
1
4
#pragma once
5
#define __XTD_STD_INTERNAL__
6
#include "
internal/__xtd_std_version.hpp
"
7
#undef __XTD_STD_INTERNAL__
8
#include "
raw_type.hpp
"
9
#include <concepts>
10
#include <iostream>
11
#include <type_traits>
12
#if defined(__xtd__cpp_lib_format)
13
#include <format>
14
#endif
15
17
namespace
xtd
{
19
33
template
<
typename
type_t>
34
struct
value_type
{
36
39
using
native_type
= type_t;
41
43
46
constexpr
value_type
() noexcept = default;
49
template<typename other_t>
50
requires std::is_same_v<
xtd
::
raw_type
<other_t>,
native_type
> && (!std::is_same_v<
xtd
::
raw_type
<other_t>,
value_type
>)
51
constexpr
value_type
(other_t&& value) noexcept : __t__ {value} {}
53
55
template
<
typename
other_t>
56
requires
std::is_same_v<xtd::raw_type<other_t>,
native_type
> && (!std::is_same_v<xtd::raw_type<other_t>,
value_type
>)
57
auto
operator =(other_t&& value)
noexcept
->
value_type
& {__t__ = value;
return
*
this
;}
58
[[nodiscard]]
constexpr
operator
native_type
() const noexcept {
return
__t__;}
59
native_type
__t__ {};
61
};
62
63
65
template
<
typename
type_t>
66
auto
operator <<(std::ostream& os,
const
xtd::value_type<type_t>
&
v
) -> std::ostream& {
return
os <<
v
.__t__;}
67
inline
auto
operator <<(std::ostream& os,
const
xtd::value_type<bool>
&
v
) -> std::ostream& {
return
os << (
v
?
"true"
:
"false"
);}
69
}
70
73
#if defined(__xtd__cpp_lib_format)
74
template
<
typename
type_t>
75
struct
std::formatter<
xtd
::
value_type
<type_t>> : std::formatter<type_t> {
auto
format
(
const
xtd::value_type<type_t>
& v, format_context& ctx)
const
{
return
std::formatter<type_t>::format(
v
.value, ctx);}};
76
template
<>
77
struct
std::formatter<
xtd
::
value_type
<bool>> : std::formatter<bool> {
auto
format
(
const
xtd::value_type<bool>
& v, format_context& ctx)
const
{
return
v
?
"true"
:
"false"
;}};
78
#endif
__xtd_std_version.hpp
xtd::format
auto format(const xtd::string &fmt, args_t &&... args) -> xtd::string
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition
format.hpp:21
xtd::raw_type
std::remove_cvref_t< value_t > raw_type
Represents a raw type alias equivalent to std::remove_cvref_t<value_t>.
Definition
raw_type.hpp:25
xtd::console_key::v
@ v
The V key.
Definition
console_key.hpp:130
xtd
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition
abstract_object.hpp:8
xtd::value_type
std::add_cv_t< type_t > value_type
Represents the read_only_span value type.
Definition
read_only_span.hpp:57
raw_type.hpp
Contains xtd::raw_type alias.
xtd::value_type::native_type
type_t native_type
Represents the native type.
Definition
value_type.hpp:39
xtd::value_type::value_type
constexpr value_type() noexcept=default
Create a new instance of the value_type.
Generated on
for xtd by
Gammasoft
. All rights reserved.