MySQL 8.3.0
Source Code Documentation
ut::Count Struct Reference

Light-weight and type-safe wrapper which serves a purpose of being able to select proper ut::new_arr* overload. More...

#include <ut0new.h>

Public Member Functions

 Count (size_t count)
 
size_t operator() () const
 

Public Attributes

size_t m_count
 

Detailed Description

Light-weight and type-safe wrapper which serves a purpose of being able to select proper ut::new_arr* overload.

Without having a separate overload with this type, creating an array of default-initialized instances of T through the ut::new_arr*(Args &&... args) overload would have been impossible because: int *ptr = ut::new_arr_withkey<int>(UT_NEW_THIS_FILE_PSI_KEY, 5); wouldn't even compile and int *ptr = ut::new_arr_withkey<int>(UT_NEW_THIS_FILE_PSI_KEY, std::forward_as_tuple(5)); would compile but would not have intended effect. It would create an array holding 1 integer element that is initialized to 5.

Given that function templates cannot be specialized, having an overload crafted specifically for given case solves the problem: int *ptr = ut::new_arr_withkey<int>(UT_NEW_THIS_FILE_PSI_KEY, ut::Count{5});

Constructor & Destructor Documentation

◆ Count()

ut::Count::Count ( size_t  count)
inlineexplicit

Member Function Documentation

◆ operator()()

size_t ut::Count::operator() ( void  ) const
inline

Member Data Documentation

◆ m_count

size_t ut::Count::m_count

The documentation for this struct was generated from the following file: