azure-sdk-for-cpp icon indicating copy to clipboard operation
azure-sdk-for-cpp copied to clipboard

Add ostream operator << for Azure::Nullable and Azure::DateTime

Open antkmsft opened this issue 2 years ago • 0 comments

This came up during a customer study, when customer could not print key vault secret, because he would need to write something like cout << secret.Value.Value.Value. cout << secret.Value should work, as well as cout << secret.Value.Value. I.e. both model types should have operator <<, and all the types that they have should have operator << recursively. Similarly, most common types inside nullable are strings, ints, bools - which all do work with operator << out of the box, and DateTime. Therefore, this work item is to:

  1. Add ostream operator << for Azure::Nullable
  2. Add ostream operator << for Azure::DateTime.

A work item to add operator << support for model types will be opened separately (#4694).

The way it would work for nullable: if null, print "null". If not null, call operator << for T. And look at the std::optional for heavy inspiration.

antkmsft avatar Jun 02 '23 22:06 antkmsft