The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

ancientlore (4) [Avatar] Offline
I am loving the book so far - this is a really good work on the topic.

I think there is a better example that could be used on page 113 on global generic functions. I found the example slightly contrived, because you would never need to write the static function version as a generic method. You would probably write it as a part of the generic Stack class:

static void MoveStack(Stack<T>^ source, Stack<T>^ dest)

Then it is easily invoked without the extra Stack<anytypename> in front:

Stack<String^>::MoveStack(source, dest);

I think there is another example though - say you want to convert one type of stack to another. That makes a really good global generic function:

generic<typename T1, typename T2>
void MoveStack(Stack<T1>^ source, Stack<T2>^ dest)
while (source->Count() > 0)

You call it like:

MoveStack<int, long>(source, dest);

As long as both stack types contain elements that can be converted with a safe_cast, you're all set.