Skip to content

Commit

Permalink
📝 Add documentation for pack
Browse files Browse the repository at this point in the history
  • Loading branch information
raidgar98 committed Nov 12, 2022
1 parent bb94159 commit 692ceea
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions include/serek/private/pack.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/**
* @file pack.hpp
* @author Krzysztof Mochocki (raidgar98@onet.pl)
* @brief Contains implementation of wrapper for class
* @version 0.1
* @date 2021-09-07
*
* @copyright Copyright (c) 2021
*
*/

#pragma once

#include <iostream>
Expand All @@ -6,19 +17,44 @@

namespace serek
{
/**
* @brief contains implementation details of `pack`
*/
namespace detail
{
/**
* @brief can be used to wrap class to be iterable over fields
*
* @tparam last_field last field
*/
template<auto last_field>
struct pack_impl;

/**
* @copydoc pack_impl
*
* @tparam owner_t type of class that is wrapped
* @tparam previous_field_t type of last field
* @tparam owner_t::*value static pointer to last field
*/
template<typename owner_t, typename previous_field_t, previous_field_t owner_t::*value>
struct pack_impl<value> : public owner_t
{
/**
* @brief Construct a new pack impl object by forwarding to base
*/
template<typename... Argv>
explicit pack_impl(Argv&&... argv) : owner_t{{std::forward<Argv>(argv)}...}
{
}

/**
* @brief forwards visitor to last field
*
* @tparam visitor_t type of visitor to forward
* @param v visitor to forward
* @return visitor_result_t
*/
template<reqs::visitor_req visitor_t>
visitor_result_t visit(visitor_t* v)
{
Expand All @@ -29,6 +65,9 @@ namespace serek
return result;
}

/**
* @copydoc visit
*/
template<reqs::visitor_req visitor_t>
visitor_result_t visit(visitor_t* v) const
{
Expand All @@ -41,6 +80,9 @@ namespace serek
};
} // namespace detail

/**
* @copydoc detail::pack_impl
*/
template<auto last_field>
using pack = typename detail::pack_impl<last_field>;
} // namespace serek

0 comments on commit 692ceea

Please sign in to comment.