xtd 0.2.0
Loading...
Searching...
No Matches
params.h
Go to the documentation of this file.
1
4#pragma once
5#include "../../object.h"
6#include "../../string.h"
7
9namespace xtd {
11 namespace collections {
13 namespace generic {
39 template<typename type_t>
40 class params final : public xtd::object {
41 public:
43
46 using base_type = std::initializer_list<type_t>;
48 using value_type = typename base_type::value_type;
50 using reference = typename base_type::reference;
52 using const_reference = typename base_type::const_reference;
54 using const_pointer = const value_type*;
56 using size_type = typename base_type::size_type;
58 using iterator = typename base_type::iterator;
60 using const_iterator = typename base_type::const_iterator;
62
64
67 constexpr params() noexcept = default;
69
71 params(const params&) noexcept = default;
72 params(params&&) noexcept = default;
73 params(const base_type& il) noexcept : items_(il) {}
74 params(base_type&& il) noexcept : items_(il) {}
76
78
83 constexpr iterator begin() const noexcept {return items_.begin();}
84
88 virtual const_pointer data() const noexcept {return reinterpret_cast<const_pointer>(begin());}
89
93 constexpr iterator end() const noexcept {return items_.end();}
94
97 virtual const base_type& items() const noexcept {return items_;}
98
101 constexpr size_type size() const noexcept {return items_.size();}
103
105
107 xtd::string to_string() const noexcept override {return xtd::string::format("{}", items_);}
109
111
115 operator const base_type&() const noexcept {return items_;}
118 operator base_type&() noexcept {return items_;}
120
121 private:
122 base_type items_;
123 };
124 }
125 }
126}
127
129namespace std {
130 template<typename type_t>
131 inline const type_t* begin(xtd::collections::generic::params<type_t> items) noexcept {
132 return items.begin();
133 }
134
135 template<typename type_t>
136 inline const type_t* end(xtd::collections::generic::params<type_t> items) noexcept {
137 return items.end();
138 }
139}
Represents text as a sequence of character units.
Definition basic_string.h:79
An object of type xtd::collections::generic::params <type_t> is a lightweight proxy object that provi...
Definition params.h:40
xtd::string to_string() const noexcept override
Returns a xtd::string that represents the current object.
Definition params.h:107
std::initializer_list< type_t > base_type
Represents the params base type.
Definition params.h:46
virtual const base_type & items() const noexcept
Returns the underlying base type items.
Definition params.h:97
typename base_type::value_type value_type
Represents the params value type.
Definition params.h:48
constexpr iterator begin() const noexcept
Returns a pointer to the first element in the params.
Definition params.h:83
typename base_type::size_type size_type
Represents the params size type (usually xtd::size).
Definition params.h:56
constexpr size_type size() const noexcept
Returns the number of elements in the params, i.e. std::distance(begin(), end()).
Definition params.h:101
constexpr iterator end() const noexcept
Returns a pointer to one past the last element in the params, i.e. begin() + size().
Definition params.h:93
virtual const_pointer data() const noexcept
Returns pointer to the underlying array serving as element storage.
Definition params.h:88
typename base_type::const_reference const_reference
Represents the const reference of params value type.
Definition params.h:52
const value_type * const_pointer
Represents the const pointer of params value type.
Definition params.h:54
typename base_type::const_iterator const_iterator
Represents the const iterator of params value type.
Definition params.h:60
constexpr params() noexcept=default
Create a new instance of the class xtd::collections::generic::params.
typename base_type::iterator iterator
Represents the iterator of params value type.
Definition params.h:58
typename base_type::reference reference
Represents the reference of params value type.
Definition params.h:50
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
static basic_string format(const basic_string< char > &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
@ end
The END key.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10