xtd
1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
xtd.core
include
xtd
register_any_stringer.hpp
Go to the documentation of this file.
1
3
#pragma once
4
#include "
collections/generic/key_value_pair.hpp
"
5
#include "
unregister_any_stringer.hpp
"
6
8
extern
std::unordered_map<std::type_index, std::function<std::string(
xtd::any
const
&)>> __any_stringer__;
9
10
template
<
typename
type_t,
typename
function_t>
11
inline
auto
__to_any_stringer__(function_t
const
& func) -> std::pair<
const
std::type_index, std::function<std::string(
xtd::any
const
&)>> {
12
return
{
13
std::type_index(
typeid
(type_t)),
14
[
f
=
func
](
xtd::any
const
&
value
)->std::string {
15
if
constexpr
(std::is_void_v<type_t>)
return
f
();
16
else
return
f
(
xtd::any_cast<const type_t&>
(value));
17
}
18
};
19
}
21
23
namespace
xtd
{
25
37
template
<
typename
type_t,
typename
function_t>
38
inline
auto
register_any_stringer
(
const
function_t&
func
) ->
void
{
39
unregister_any_stringer<type_t>
();
40
__any_stringer__.insert(__to_any_stringer__<type_t>(
func
));
41
}
42
43
}
xtd::func
xtd::delegate< result_t(arguments_t... arguments)> func
Represents a delegate that has variables parameters and returns a value of the type specified by the ...
Definition
func.hpp:27
xtd::expressions::operator_precedence::value
@ value
Represnets the constant operator precedence (42).
Definition
operator_precedence.hpp:30
xtd::register_any_stringer
auto register_any_stringer(const function_t &func) -> void
Register an any stringer method for a specified type.
Definition
register_any_stringer.hpp:38
xtd::unregister_any_stringer
auto unregister_any_stringer() -> void
Unregister an any stringer method for a specified type.
Definition
unregister_any_stringer.hpp:33
xtd::any
std::any any
Represents the any alias on std::any.
Definition
any.hpp:24
xtd::any_cast
auto any_cast(const xtd::any &operand) -> type_t
Performs type-safe access to the contained object.
Definition
any_cast.hpp:22
xtd::console_key::f
@ f
The F key.
Definition
console_key.hpp:98
key_value_pair.hpp
Contains xtd::collections::generic::key_value_pair <key_t, value_t> struct.
xtd
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition
abstract_object.hpp:8
unregister_any_stringer.hpp
Contains xtd::register_any_stringer and xtd::unregister_any_stringer method.
Generated on
for xtd by
Gammasoft
. All rights reserved.