bounded-types

Question on Java Generics Bounded Wildcard

Is there a difference between 1) <N extends Number> Collection<N> getThatCollection(Class<N> type) and 2) Collection<? extends Number> getThatCollection(Class<? extends Number>) ...

Combining bounded wildcards in Java

Is there anyway to use a bounded wildcard require a class implement more than one interface? In otherwords, something like... class Foo<S extends Comparable && Clonable> ...which would require that objects extend both interfaces? I realize I can make another ComparableAndClonable which extends the two but I don't have control over...

Is it possible to write a generic +1 method for numeric box types in Java?

This is NOT homework. Part 1 Is it possible to write a generic method, something like this: <T extends Number> T plusOne(T num) { return num + 1; // DOESN'T COMPILE! How to fix??? } Short of using a bunch of instanceof and casts, is this possible? Part 2 The following 3 methods compile: Integer plusOne(Integer num) { ...

How to iterate through a sequence of bounded types with Boost.Variant

struct A { std::string get_string(); }; struct B { int value; }; typedef boost::variant<A,B> var_types; std::vector<var_types> v; A a; B b; v.push_back(a); v.push_back(b); How can I iterate iterate through the elements of v to get access to the a and b objects ? I'm able to do it with boost::get b...

In Java type arguments, does <? extends E> mean strictly subtypes only? or would E also suffice?

In Java type arguments, does mean strictly subtypes only? or would E also suffice? ...