Questions tagged [covariance]

Covariance, contravariance and invariance describe how the existing type inheritance hierarchy changes when subjected to some transformation (such as usage within generics). If the transformation keeps the ordering of the original hierarchy, it is "covariant". If it reverses it, it is "contravariant". If it breaks it, it is "invariant".

Filter by
Sorted by
Tagged with
4
votes
1answer
100 views

C++ covariant_invoke

This utility function invokes one of a list of functions which are covariant on the provided value. It reduces boilerplate by internally performing dynamic_cast on the input value, and invokes the ...
2
votes
0answers
301 views

Imitate Qt Quick's QQuickFramebufferObject, but do the syncing more tidily (with covariance)

I'm making a system similar to Qt Quick with its scenegraph. Since it's embedded within Qt Quick with its threading system, the items' Renderers should sync some ...
9
votes
1answer
469 views

A Covariant Tuple

I was searching for a way to put a Tuple<List> into a Tuple<IEnumerable>, and I found that Tuple has no covariance. ...
4
votes
3answers
2k views

“fake” covariance in PHP type-hinting

Here's the situation: I've got several distinct objects, each with their own responsability and (therefore) each their own dependencies. As this is code that will be implemented in 2 existing ...
3
votes
2answers
6k views

Sequential Execution: Orchestrator Pattern

I built a code piece that makes it easy to execute a set of sequential operations, that might depend on the same parameter value (passed across the execution) or might need a particular parameter. ...