I have the following structs:
struct A
{
}
struct B
{
tuple<string,string> children{{"test1","test2"}};
}
I would like to create a template function that will overload the << operator on every class having a member variable called children. If possible- only on tuples named children.
When a class with a children tuple like B is met it should iterate the tuple members and call << on each of them.
Something like:
template<typename RECEIVERTYPE,typename SENDERTYPE>
typename std::enable_if<std::have_children_member<RECEIVER_TYPE>::value, void>::type
RECEIVERTYPE& operator<< (RECEIVERTYPE& streamReceiver, const SENDERTYPE& streamSender)
{
for_each(streamSender.children, [&](const auto& child)
{
streamReceiver << child;
});
return streamReceiver;
}
I have tried alot of examples- but I cant really get anything working in visual studio 2015.
I would just do this to only match types with a tuple member called
children
:And might implement the body like this:
Or like: