G
Good Guy
I have following two classes:
template <size_t size>
class Cont{
public:
char charArray[size];
};
template <size_t size>
class ArrayToUse{
public:
Cont<size> container;
inline ArrayToUse(const Cont<size+1> &
input):container(reinterpret_cast<const Cont<size> &>(input)){}
};
I have two following lines of code at global scope:
const Cont<12> container={"hello world"};
ArrayToUse<11> temp(container);
char (&charArray)[11]=temp.container.charArray;
In totality of my code The only usage of "container" object is for
initialization of an object of "ArrayToUse" class as mentioned and
after initialization of "charArray" reference to
"temp.container.charArray" I'll use that reference in rest of my code,
now I'm wondering whether after building the code memory will be
reserved for "container" object or not since that's got a temporary
usage.
template <size_t size>
class Cont{
public:
char charArray[size];
};
template <size_t size>
class ArrayToUse{
public:
Cont<size> container;
inline ArrayToUse(const Cont<size+1> &
input):container(reinterpret_cast<const Cont<size> &>(input)){}
};
I have two following lines of code at global scope:
const Cont<12> container={"hello world"};
ArrayToUse<11> temp(container);
char (&charArray)[11]=temp.container.charArray;
In totality of my code The only usage of "container" object is for
initialization of an object of "ArrayToUse" class as mentioned and
after initialization of "charArray" reference to
"temp.container.charArray" I'll use that reference in rest of my code,
now I'm wondering whether after building the code memory will be
reserved for "container" object or not since that's got a temporary
usage.