c++ - Using make_shared with char[] or int[] -
can tell me if works in vs2015 ?
shared_ptr< char> buffer( make_shared< array< char,10>>() , [] (char *p){delete[] p; } );
or
shared_ptr< char> buffer( make_shared< array< int,10>>() ,default_delete< int[]>());
visual studio 2015 doesn't support c++17 standard. prior c++17 standard can't have std::shared_ptr<t[]>
pointer. in c++17 std::make_shared function doesn't support array types have use boost::make_shared instead. alternative use unique pointer in combination std::make_unique support array types. again might not idea pointed out scot meyers in "effective modern c++" book:
the existence of std::unique_ptr arrays should of intellectual interest you, because std::array, std::vector, , std::string virtually better data structure choices raw arrays.
Comments
Post a Comment