Declaring a class that works with two constrained generic types