MCPcopy Create free account
hub / github.com/covscript/covscript / basic_var

Class basic_var

include/covscript/core/variable.hpp:409–442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

407 template <std::size_t align_size,
408 template <typename> class allocator_t = default_allocator>
409 class basic_var final {
410 friend class any;
411
412 static_assert(align_size % 8 == 0, "align_size must be a multiple of 8.");
413 static_assert(align_size >= aligned_element_size,
414 "align_size must greater than alignof(std::max_align_t).");
415
416 using aligned_storage_t = std::aligned_storage_t<align_size - aligned_element_size, alignof(std::max_align_t)>;
417
418 template <typename T>
419 struct var_op_svo_dispatcher
420 {
421 static COVSCRIPT_ALWAYS_INLINE operators::result op_copy(void *lhs, void *rhs)
422 {
423 static_assert(std::is_copy_constructible<T>::value, "CovScript requires type supports copy constructor.");
424 ::new (&static_cast<basic_var *>(rhs)->m_store.buffer) T(*static_cast<const T *>(lhs));
425 return operators::result();
426 }
427 static COVSCRIPT_ALWAYS_INLINE operators::result op_move(void *lhs, void *rhs) noexcept
428 {
429 static_assert(std::is_move_constructible<T>::value, "CovScript requires type supports move constructor.");
430 ::new (&static_cast<basic_var *>(rhs)->m_store.buffer) T(std::move(*static_cast<T *>(lhs)));
431 return operators::result();
432 }
433 static COVSCRIPT_ALWAYS_INLINE operators::result op_swap(void *lhs, void *rhs) noexcept
434 {
435 std::swap(*static_cast<T *>(lhs), static_cast<basic_var *>(rhs)->template unchecked_get<T>());
436 return operators::result();
437 }
438 static COVSCRIPT_ALWAYS_INLINE operators::result op_destroy(void *lhs, void *rhs)
439 {
440 static_cast<T *>(lhs)->~T();
441 return operators::result();
442 }
443 template <typename... ArgsT>
444 static COVSCRIPT_ALWAYS_INLINE void construct(basic_var *val, ArgsT &&...args)
445 {

Callers

nothing calls this directly

Calls 1

resultFunction · 0.85

Tested by

no test coverage detected