I want to map from class tokens to instances along the lines of the following code:

```
trait Instances {
  def put[T](key: Class[T], value: T)
  def get[T](key: Class[T]): T
}

```

Can this be done without having to resolve to casts in the get method?

**Update:**

How could this be done for the more general case with some `Foo[T]` instead of `Class[T]`?