Defined in header <fkYAML/node.hpp>
fkyaml::basic_node::value_converter_type¶
A helper type alias to determine converter type for the given target native data type T
.
The default type of the template parameter ValueConverterType
is node_value_converter
.
This type alias is used to determine the target type T
is convertible from/to basic_node
.
The function get_value
relies on it internally.
If you want to convert some type from/to basic_node
, however, it is recommended to use basic_node::get_value
instead, in order both to make your program more understandable and to avoid too much dependency on the fkYAML library implementation.
Template Parameters¶
- T
- The target native data type.
- SFINAE
- Type to add compile type checks via SFINAE. Usually
void
is given.
Example
#include <iomanip>
#include <iostream>
#include <type_traits>
#include <fkYAML/node.hpp>
int main() {
std::cout << std::boolalpha
<< std::is_same<
fkyaml::node_value_converter<double, void>,
fkyaml::node::value_converter_type<double, void>>::value
<< std::endl;
fkyaml::node n = 3.14;
double d = 0.0;
// This leads to the same result as `d = n.get_value<double>()`.
fkyaml::node::value_converter_type<double, void>::from_node(n, d);
std::cout << std::setprecision(3) << d << std::endl;
return 0;
}
output: