Link: Effective modern C ++. Item 4.
https://github.com/BartVandewoestyne/Effective-Modern-Cpp/blob/master/Item04_Know_how_to_view_deduced_types/runtime_output02.cpp
class Widget {}; template<typename T> // template function to void f(const T& param) // be called { } std::vector<Widget> createVec() // factory function { std::vector<Widget> vw; Widget w; vw.push_back(w); return vw; } int main() { const auto vw = createVec(); // init vw w/factory return if (!vw.empty()) { f(&vw[0]); // call f // ... } }
Based on the book as a type T, and paramis as follows:
T
param
T = class Widget const * param = class Widget const * const &
I have problems to understand why param- this type with the above f(const T& param).
f(const T& param)
Here is my understanding
T = class Widget const *
So, f(const T& param)it becomes the following:
f(const const Widget * & param).
f(const const Widget * & param)
Why is the real type paramsmaller Widget const * const &?
Widget const * const &
s > Widget const * const ?
, ... T - , const T & ( T const &, , const ) T, .
const T &
T const &
const
, cont *.
cont
*
: const T & T const &; T, const Widget *, T const & const Widget * const & , , Widget const * const &
const Widget *
const Widget * const &
const const ( const const).
* const. Widget const * const (Widget), Widget * const const -const (Widget), Widget const * const const const (Widget).
Widget const *
Widget
Widget * const
Widget const * const
T = Widget const *, const; , const T, const T , , , const T Widget const * const.
T = Widget const *
const T
Source: https://habr.com/ru/post/1666062/More articles:Обработка ошибок в макросе cljc - clojureResize icon BottomNavigationView - androidhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1666059/how-flink-authenticates-to-elastic-search-sink-with-shield-plugin&usg=ALkJrhjDRJFUbN-3_l2Qz5CIhIwW7a7uaQHow to increase the bottom navigation View height along with its icons and text sizes in android? - androidWebpack build process - module not found: Error: cannot enable module * - buildObjective-C enter the block type in another, getting an unexpected result - floating-pointAngular 2: Unable to add a group of forms to form an array in reactive forms - javascriptGetting problems registering contorl with a form in Angular Reactive forms - angularEdit / Delete classes in external files of third-party jar libraries in android? - javaNeed to clarify YII2 events - phpAll Articles