Skip to content

Commit

Permalink
Merge branch 'decay'
Browse files Browse the repository at this point in the history
  • Loading branch information
pfultz2 committed Aug 28, 2015
2 parents 95de65d + d5835d3 commit ee2d556
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 12 deletions.
54 changes: 54 additions & 0 deletions fit/decay.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*=============================================================================
Copyright (c) 2015 Paul Fultz II
decay.h
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/

#ifndef FIT_GUARD_DECAY_H
#define FIT_GUARD_DECAY_H

/// decay
/// =====
///
/// Description
/// -----------
///
/// The `decay` function is a unary function object that returns whats given to it after decaying its type.
///
/// Synopsis
/// --------
///
/// struct
/// {
/// template<class T>
/// constexpr typename decay<T>::type operator()(T&& x) const
/// {
/// return fit::forward<T>(x);
/// }
/// } decay;
///

#include <fit/detail/unwrap.h>
#include <fit/detail/static_const_var.h>
#include <fit/detail/forward.h>

namespace fit { namespace detail {

struct decay_f
{
template<class T>
constexpr typename unwrap_reference<typename std::decay<T>::type>::type
operator()(T&& x) const
{
return fit::forward<T>(x);
}
};

}

FIT_DECLARE_STATIC_VAR(decay, detail::decay_f);

}

#endif
14 changes: 2 additions & 12 deletions fit/pack.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include <fit/detail/static_const_var.h>
#include <fit/returns.h>
#include <fit/alias.h>
#include <fit/decay.h>

#ifndef FIT_HAS_RVALUE_THIS
#define FIT_HAS_RVALUE_THIS 1
Expand All @@ -77,17 +78,6 @@

namespace fit { namespace detail {

struct decay_elem_f
{
template<class T>
constexpr typename unwrap_reference<typename std::decay<T>::type>::type
operator()(T&& x) const
{
return fit::forward<T>(x);
}
};
static decay_elem_f decay_elem = {};

template<class...>
struct pack_tag
{};
Expand Down Expand Up @@ -289,7 +279,7 @@ struct pack_decay_f
template<class... Ts>
constexpr auto operator()(Ts&&... xs) const FIT_RETURNS
(
pack_f()(decay_elem(fit::forward<Ts>(xs))...)
pack_f()(decay(fit::forward<Ts>(xs))...)
);
};

Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pages:
- 'always': 'always.md'
- 'args': 'args.md'
- 'construct': 'construct.md'
- 'decay': 'decay.md'
- 'identity': 'identity.md'
- 'placeholders': 'placeholders.md'
- Utilities:
Expand Down

0 comments on commit ee2d556

Please sign in to comment.