MCPcopy Create free account
hub / github.com/covscript/covscript / result op_swap

Method result op_swap

include/covscript/core/variable.hpp:512–539  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

510
511 template <typename T>
512 struct var_op_heap_dispatcher
513 {
514 static allocator_t<T> &get_allocator()
515 {
516 static allocator_t<T> allocator;
517 return allocator;
518 }
519 static COVSCRIPT_ALWAYS_INLINE operators::result op_copy(void *lhs, void *rhs)
520 {
521 static_assert(std::is_copy_constructible<T>::value, "CovScript requires type supports copy constructor.");
522 T *nptr = get_allocator().allocate(1);
523 ::new (nptr) T(*static_cast<const T *>(lhs));
524 static_cast<basic_var *>(rhs)->m_store.ptr = nptr;
525 return operators::result();
526 }
527 static COVSCRIPT_ALWAYS_INLINE operators::result op_move(void *lhs, void *rhs) noexcept
528 {
529 static_assert(std::is_move_constructible<T>::value, "CovScript requires type supports move constructor.");
530 T *nptr = get_allocator().allocate(1);
531 ::new (nptr) T(std::move(*static_cast<T *>(lhs)));
532 static_cast<basic_var *>(rhs)->m_store.ptr = nptr;
533 return operators::result();
534 }
535 static COVSCRIPT_ALWAYS_INLINE operators::result op_swap(void *lhs, void *rhs) noexcept
536 {
537 std::swap(*static_cast<T *>(lhs), static_cast<basic_var *>(rhs)->template unchecked_get<T>());
538 return operators::result();
539 }
540 static COVSCRIPT_ALWAYS_INLINE operators::result op_destroy(void *lhs, void *rhs)
541 {
542 T *ptr = static_cast<T *>(lhs);

Callers

nothing calls this directly

Calls 2

resultFunction · 0.85
swapFunction · 0.70

Tested by

no test coverage detected