In trying to learn how to use std::aligned_union I am having trouble finding any examples. My attempt is running into problems that I do not know how to solve.
struct include
{
std::string file;
};
struct use
{
use(const std::string &from, const std::string &to) : from{ from }, to{ to }
{
}
std::string from;
std::string to;
};
std::aligned_union<sizeof(use), include, use>::type item;
*reinterpret_cast<use*>(&item_) = use{ from, to };
When I attempt to run the program in VC++2013 debug mode I get a runtime error in memcpy(unsigned char * dst, unsigned char * src, unsigned long count)
. I assume that this is how VC++ implements the assignment from the temporary.
How would I change this so that I do not have this issue?