Does it make sense to combine optional with reference_wrapper?

Is there any conceptual difference between std::optional<std::reference_wrapper<T>> and T*? std::optional<>, as the name already suggest, is meant to be used when we could have a value or might not have any value at all. The equivalent of having no value for a T* object would be assigning nullptr to it, i.e.: the pointer will point … Read more

WCF Service Reference generates its own contract interface, won’t reuse mine

“Reuse types in referenced assemblies” only allows you to reuse Data Contracts, not Service Contracts. If you want to share Service Contracts, you don’t need to use “Add Service Reference” at all. You can just use ChannelFactory directly. // Supply the binding and address in code Binding binding = new BasicHttpBinding(); EndpointAddress address = new … Read more

Assignment operator with reference members

It’s syntactically correct. If the placement new throws, however, you end up with an object you can’t destruct. Not to mention the disaster if someone derives from your class. Just don’t do it. The solution is simple: if the class needs to support assignment, don’t use any reference members. I have a lot of classes … Read more

What is the difference between a function call and function reference?

Well, the onclick property expects a reference to a function, for it to execute when the element is clicked. Normally it’s either: element.onclick = funcRef; or element.onclick = function () { funcRef(); }; (but of course, it’s best to use addEventListener and attachEvent) Notice how both of them are references to functions, not calling. When … Read more