Home > Blockchain >  How the intelisense for std::make_shared() know the default constructor arguments? Is it Visual Stud
How the intelisense for std::make_shared() know the default constructor arguments? Is it Visual Stud

Time:01-27

std::make_shared() is used to construct an object directly as shared_ptr and to call the constructor of given type it takes the arguments of the type's constructor. How can it know the arguments and definitions of the type's constructors? when using templates and ... operator visual studio intellisense can't show the definitions of type's constructors but will only show the generic definition of template, but std::make_shared() can show the precise definition of the constructors. is it a feature of visual studio intellisense and specific for standard library functions or is it something I couldn't guess in c implementation of std::make_shared()? is so, how can I recreate it?

template<typename T, typename... types>
std::shared_ptr<T> my_make_shared(types... args) {
    return std::shared_ptr<T>(new T(args...));
}

here is how it looks like for std::make_shared() enter image description here

  • Related