Skip to content

Commit

Permalink
add move impl (#544)
Browse files Browse the repository at this point in the history
Co-authored-by: Dhaibat Chaudhuri <[email protected]>
  • Loading branch information
dhaibatc and Dhaibat Chaudhuri authored Apr 8, 2024
1 parent ea12e06 commit b335261
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/libraries/utility.hpp/f_move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
layout: function
title: move
hyde:
owner: dhaibatc
brief: __INLINED__
tags:
- function
inline:
brief:
- A standard move implementation but with a compile-time check for const types.
defined_in_file: utility.hpp
overloads:
"template <class T>\nconstexpr std::remove_reference_t<T> && move(T &&)":
arguments:
- description: __OPTIONAL__
name: t
type: T &&
description: __INLINED__
inline:
description:
- A standard move implementation but with a compile-time check for const types.
return: __OPTIONAL__
signature_with_names: "template <class T>\nconstexpr std::remove_reference_t<T> && move(T && t)"
namespace:
- stlab
- v2
---
10 changes: 10 additions & 0 deletions stlab/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ constexpr std::decay_t<T> copy(T&& value) noexcept(noexcept(std::decay_t<T>{

/**************************************************************************************************/

/// A standard move implementation but with a compile-time check for const types.
template <class T>
constexpr std::remove_reference_t<T>&& move(T&& t) noexcept {
static_assert(!std::is_const_v<std::remove_reference_t<T>>,
"move of const type will unintentionally decay to copy");
return static_cast<std::remove_reference_t<T>&&>(t);
}

/**************************************************************************************************/

} // namespace STLAB_VERSION_NAMESPACE()
} // namespace stlab

Expand Down

0 comments on commit b335261

Please sign in to comment.