Question: In c++, Write a templated function (named make_double) that takes two arguments: An array pointer reference of a templated type A size_t reference which is

In c++, Write a templated function (named "make_double") that takes two arguments:

An array pointer reference of a templated type

A size_t reference which is the size of the array

This function should make the array pointer reference point at a new dynamic array that is twice the size and has two copies of each original value in the array. It should also make the sz reference have the double size.

// Example usecase: #include  using std::copy; #include  using std::vector; size_t sz = 3; long * ary_ptr = new long[sz]{1, 2, 3}; make_double(ary_ptr, sz); ASSERT_EQ(6, sz); vector expected{1, 2, 3, 1, 2, 3}; vector result(sz); copy(ary_ptr, ary_ptr + sz, result.begin()); ASSERT_EQ(expected, result); 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!