Just have a generic abstract class with the required public interface, then have two implementations of it, generic one, and a special one for trivially copyable types. Then you can have a factory, that creates an instance based on the element type. Can be done in Java and C# alike.