template<typename... Params>
named_tuple struct
named_
Its main purpose is to make more readable and less error prone code that uses std::tuple
.
using namespace BipedalLocomotion::GenericContainer::literals; auto foo = BipedalLocomotion::GenericContainer::make_named_tuple(BipedalLocomotion::GenericContainer::named_param<"name"_h, std::string>(), BipedalLocomotion::GenericContainer::named_param<"number"_h, int>()); // it is still possible to access the elements of the named_tuple with structured binding // declaration auto& [a, b] = foo; b = 150; // moreover you can call std::get<> as usual int n = std::get<1>(foo); // Differently from a normal tuple it is possible to access to the element via the hash as // follows foo.get_from_hash<"name"_h>() = "Smith"; const std::string& temp_string = foo.get_from_hash<"name"_h>();
Public types
- using underlying_tuple = std::tuple<typename Params::Type...>
- Underlying tuple that can be generate from this named_
tuple.
Constructors, destructors, conversion operators
- named_tuple() constexpr
- Constructor.
- named_tuple(Params && ... args)
- Constructor.
-
template<typename... Args>named_tuple(const std::tuple<Args...>& t)
- Construct from a tuple.
-
template<typename... Args>named_tuple(std::tuple<Args...>&& t)
- Construct from a tuple.
Public functions
-
template<typename... Args>auto operator=(const std::tuple<Args...>& t) -> named_
tuple& - Copy from a tuple.
-
template<std::size_t I>auto get() const -> const std::tuple_element<I, underlying_
tuple>::type& noexcept - Extracts the Ith element from the named_
tuple. -
template<std::size_t I>auto get() -> std::tuple_element<I, underlying_
tuple>::type& noexcept - Extracts the Ith element from the named_
tuple. -
template<hash_type Hash>auto get_from_hash() const -> const auto& noexcept
- Extracts the element from the named_
tuple associated to the hash Hash
. -
template<hash_type Hash>auto get_from_hash() -> auto& noexcept
- Extracts the element from the named_
tuple associated to the hash Hash
. -
auto to_tuple() const -> underlying_
tuple noexcept - Return the associated std::tuple.
Function documentation
template<typename... Params>
template<typename... Args>
BipedalLocomotion:: GenericContainer:: named_tuple<Params>:: named_tuple(const std::tuple<Args...>& t)
Construct from a tuple.
Parameters | |
---|---|
t | a tuple having the same number of elements of of named_ |
template<typename... Params>
template<typename... Args>
BipedalLocomotion:: GenericContainer:: named_tuple<Params>:: named_tuple(std::tuple<Args...>&& t)
Construct from a tuple.
Parameters | |
---|---|
t | a tuple having the same number of elements of named_ |
template<typename... Params>
template<typename... Args>
named_ tuple& BipedalLocomotion:: GenericContainer:: named_tuple<Params>:: operator=(const std::tuple<Args...>& t)
Copy from a tuple.
Parameters | |
---|---|
t | tuple |
template<typename... Params>
template<std::size_t I>
const std::tuple_element<I, underlying_ tuple>::type& BipedalLocomotion:: GenericContainer:: named_tuple<Params>:: get() const noexcept
Extracts the Ith element from the named_
Returns | A reference to the selected element of t. |
---|
It must be an integer value in [0, sizeof...(Types))
.
template<typename... Params>
template<std::size_t I>
std::tuple_element<I, underlying_ tuple>::type& BipedalLocomotion:: GenericContainer:: named_tuple<Params>:: get() noexcept
Extracts the Ith element from the named_
Returns | A reference to the selected element of t. |
---|
I must be an integer value in [0, sizeof...(Types))
.
template<typename... Params>
template<hash_type Hash>
const auto& BipedalLocomotion:: GenericContainer:: named_tuple<Params>:: get_from_hash() const noexcept
Extracts the element from the named_Hash
.
Hash
must be among one of the hash values associated to the tuple when created. @return A reference to the selected element of t.
template<typename... Params>
template<hash_type Hash>
auto& BipedalLocomotion:: GenericContainer:: named_tuple<Params>:: get_from_hash() noexcept
Extracts the element from the named_Hash
.
Hash
must be among one of the hash values associated to the tuple when created. @return A reference to the selected element of t.
template<typename... Params>
underlying_ tuple BipedalLocomotion:: GenericContainer:: named_tuple<Params>:: to_tuple() const noexcept
Return the associated std::tuple.
Returns | the tuple associated to the named_ |
---|