25 var(
const var& src) : _inner(src._inner->clone()) {}
27 template <
typename _Ty>
var(_Ty src) : _inner(new inner<_Ty>(src)) {}
29 template <
typename _Ty>
var& operator = (_Ty src) {
30 var oTmp(std::forward<_Ty>(src));
31 std::swap(oTmp, *
this);
35 var& operator=(
const var& src) {
36 if (&src ==
this)
return *
this;
37 _inner.reset(src._inner->clone());
41 const std::type_info& get_type()
const {
return _inner->get_type(); }
43 bool is_pod()
const {
return _inner->is_pod(); }
45 size_t size()
const {
return _inner->size(); }
47 template <
typename _Ty> _Ty& as() {
48 return *
dynamic_cast<inner<_Ty>&
>(*_inner);
51 template <
typename _Ty>
const _Ty& as()
const {
52 return *
dynamic_cast<inner<_Ty>&
>(*_inner);
57 using ptr = std::unique_ptr < inner_base >;
60 virtual const std::type_info& get_type()
const = 0;
61 virtual bool is_pod()
const = 0;
62 virtual size_t size()
const = 0;
70 ~
empty()
override =
default;
72 const std::type_info& get_type()
const override {
return typeid(
empty); }
73 bool is_pod()
const override {
throw std::runtime_error(
"reference to uninitialized variable"); }
74 size_t size()
const override {
throw std::runtime_error(
"reference to uninitialized variable"); }
79 explicit inner(_Ty newval) : _value(newval) {}
80 ~
inner()
override =
default;
85 const std::type_info& get_type()
const override {
return typeid(_Ty); }
86 _Ty & operator * () {
return _value; }
87 const _Ty & operator * ()
const {
return _value; }
88 bool is_pod()
const override {
return std::is_pod<_Ty>::value; }
89 size_t size()
const override {
return sizeof(_Ty); }
94 inner_base::ptr _inner;
97 template <
typename _ChT>
101 ~
inner()
override =
default;
106 const std::type_info& get_type()
const override {
return typeid(
xtd::xstring<_ChT>); }
108 const std::basic_string<_ChT> & operator * ()
const {
return _value; }
109 bool is_pod()
const override {
return false; }
110 size_t size()
const override {
return _value.size(); }
specializations of std::basic_string for advanced and common string handling
host, target and build configurations and settings Various components are purpose built for specific ...
Extends std::string with some added functionality.
The var class implements a minimal type erasure idiom.
var()
Default constructs a var object with an underlying empty object.