Skip to main content
Filter by
Sorted by
Tagged with
-1 votes
0 answers
24 views

trait Sub {} trait Super { type SubT: Sub; } // Should we write struct SuperFirst<SUP, SUB> { // Fields are private sup: SUP, sub: SUB, } fn build_1<SUP, SUB>(_: SUP) -&...
Sprite's user avatar
  • 4,147
3 votes
1 answer
155 views

I am implementing a message passing mechanism in a multi-threaded Delphi 2010 VCL application. My background threads need to send various DTO records to the main UI thread. I am using a generic ...
Sashko1121's user avatar
3 votes
3 answers
130 views

The following test renders fine in my IDE (Eclipse), but fails to compile when building via Maven. The compiler error is shown in the comment line in the code block below. It looks like the compiler ...
Kevin Day's user avatar
  • 16.6k
2 votes
1 answer
166 views

When trying the following code it will not compile as I receive this error: Type parameter 'T' is not compatible with type TBase I want this type constraint to support the Save method being typed to ...
Richard Shuck's user avatar
1 vote
1 answer
104 views

Given the base class: public abstract class EnumType<TEnum, TValue> where TEnum : struct, IConvertible where TValue : struct { public abstract TEnum GetEnumValue(TValue value); } ...
Weifen Luo's user avatar
1 vote
1 answer
79 views

It is possible to make a call to a specific implementation of a generic method on a struct, ex: impl Printer<i16> { pub fn run() { println!("Specific i16"); } } Printer::<i16&...
Tim's user avatar
  • 4,885
0 votes
2 answers
229 views

I want to be able to write a function such as below, but can't get the typeinfo or type reference for the unconstrained generic type of TMyBase<T>. type TBase<T> = class end; ...
Richard Shuck's user avatar
Advice
0 votes
8 replies
111 views

The problem I am trying to solve is representing a partially loaded tree of objects using C# generics. For example, suppose we have the following classes: public class Address { public string ...
Jeremy Salwen's user avatar
5 votes
1 answer
123 views

I am using the winnow crate to write a parser and am struggling with adding tests due to lifetime conflicts. The basic setup I have is a stateful stream: // The primary stream type type SStream<'i, ...
JohnT's user avatar
  • 115
2 votes
2 answers
126 views

The following code generates CS1503 with the message: error CS1503: Argument 1: cannot convert from '<null>' to 'T?' public class MyClass<T> where T : notnull { // This is the only ...
Jeff G's user avatar
  • 4,735
-3 votes
3 answers
251 views

I’m trying to implement a generic utility method that takes a String value and a Class<?> type, and returns an instance of that type. The context: This value represents data from a JPA column, ...
David Todorov's user avatar
1 vote
6 answers
136 views

I want to write a method that converts a collection of generic type elements into a human-readable string. This method should also work with nested collections. I haven't found a better approach than ...
Human's user avatar
  • 53
0 votes
0 answers
95 views

I need to store an array of weak referenced protocols: class Weak<T: AnyObject> { weak var value: T? init (_ value: T) { self.value = value } } protocol ...
sudoExclamationExclamation's user avatar
0 votes
0 answers
43 views

I have written a SIMD interpolator like this: public struct Fade_SIMD8 { public init() {} public func interpolate(_ t: SIMD8<Float>, between a: SIMD8<Float>, and b: SIMD8<...
AirXygène's user avatar
  • 3,041
0 votes
1 answer
58 views

In TypeScript, it is possible to define a type of a constructable class using new(...args: any): // We have some class inheritance abstract class Something {} class ChildOfSomething extends Something {...
goose_lake's user avatar
  • 1,627
1 vote
0 answers
41 views

Using RestTemplate in Spring Boot to connect to a server, I have this generic class to map responses from the server I'm connecting to: @Data public class ServicesResponseDTO<T> implements ...
user2087103's user avatar
1 vote
0 answers
87 views

I am very new to development with ORMs. In my project, where I use Entity Framework Core, I want to create a class that would encapsulate whole interaction with database, i.e. through which I would ...
Alex's user avatar
  • 11
2 votes
3 answers
70 views

Say I have the following trait and classes: trait T[C1, C2, C3, C4] case class A() extends T[Int, Double, Long, String] case class B() extends T[Int, Double, Long, String] case class C() extends T[...
user79074's user avatar
  • 5,412
1 vote
3 answers
183 views

I’m trying to understand the difference between assignment and casting in Java generics. Consider the following examples: List<Integer> ints = new ArrayList<>(); List<Number> nums = ...
AMZ's user avatar
  • 400
0 votes
1 answer
82 views

I have several DataGrid (actually an UserControl based on a DataGrid with filtering dialog, etc.) in a WPF project which show ObservableCollection<VisualXModel> entities where VisualXModel ...
Ludovic Wagner's user avatar
3 votes
2 answers
147 views

I have the following inheritance structure: class S: ... class A(S): ... class B(S): ... I'd like to conceptually do something like the following: class Foo: T = TypeVar('T', bound=...
bossi's user avatar
  • 1,744
2 votes
1 answer
136 views

I'm trying to write a function that performs a binary operation on either floating-point numbers or integers. My attempt: data MyNum = F Float | I Int performBinaryOperation :: (Num a) => (a -> ...
Jacob Lockard's user avatar
0 votes
1 answer
75 views

I’m trying to use Predicate with generics but I keep getting the following compilation error : Cannot convert value of type 'PredicateExpressions.Equal<PredicateExpressions.ConditionalCast<...
Nonouf's user avatar
  • 400
5 votes
3 answers
253 views

Suppose I have a class parametrized by a type in Python 3.13: class Foo[T]: ... I want to define and type-annotate a method that should work with any Foo[T] instance, regardless of the concrete type ...
Frank William Hammond's user avatar
1 vote
1 answer
114 views

I'm trying to adapt some old sample DSP code from a conference to learn Rust generics. I'm having trouble with E0283 - I want the compiler to infer a type but I don't think my trait implementations ...
James Mclaughlin's user avatar

1
2 3 4 5
1035