generic-programming Questions
4
Solved
I was making a base class so that all bindings for child will be set in base
I have done till this
abstract class BaseActivity2<B : ViewBinding?, T : BaseViewModel?> : AppCompatActivity() {
...
Placeman asked 1/9, 2020 at 10:56
2
So I'm trying to make a type trait that says whether two "outer" class types are the same.
ie. std::vector<int> is the same as std::vector<double>, I don't care about any inner argumen...
Teniafuge asked 4/12, 2019 at 15:59
10
Solved
How does python handle generic/template type scenarios? Say I want to create an external file "BinaryTree.py" and have it handle binary trees, but for any data type.
So I could pass it the type o...
Stammel asked 17/7, 2011 at 18:30
2
Solved
Assuming you have case classes like the following
case class Test1(a:String,b:Int,c:Char)
case class Test2(a:String,b:Int)
And you instantiate the classes with the following variables
val test...
Petrolatum asked 21/4, 2014 at 7:17
17
Solved
Just attempting this question I found in a past exam paper so that I can prepare for an upcoming Java examination.
Provide a generic class Pair for representing pairs of things. The class should p...
Atp asked 18/5, 2011 at 12:50
6
Solved
I'm trying to test for a generic type in Kotlin.
if (value is Map<String, Any>) { ... }
But the compiler complains with
Cannot check for instance of erased type: jet.Map
The check wit...
Twostep asked 31/10, 2012 at 9:7
1
Context
In my code, I have an interface called AbstactDataModel that is used as a starting point for all the data model classes. This is implemented so that i know that whatever xyzModel class I ma...
Preeminence asked 7/9, 2020 at 14:25
6
I have three types of data link: RS485, I2C and Bluetooth. Every data link have functions like connect, read and write data. On PC software I must implement application/protocols layers to work wit...
Bevus asked 21/8, 2017 at 19:52
7
FUNC(param);
When param is char *,dispatch to func_string.
when it's int,dispatch to func_int
I think there may be a solution to this,as variable types are known at compile time..
Liederman asked 31/8, 2011 at 11:21
2
I am trying to create an abstract data model where i pass data and type a and then is return list, but when i can't call T.fromJson() method, note that passes type has method fromJson()
class Data...
Orphanage asked 19/11, 2018 at 6:19
3
Solved
Let us say we have
data D = X Int | Y Int Int | Z String
I wish to have a function getDConst
getDConst :: D -> String
that returns either "X", "Y", or "Z", according to the data constructo...
Roam asked 18/8, 2013 at 8:39
3
Solved
I would like to program some procedure that will work with different types. I am planning to use the "include" method used in flibs described here and here. I give here a simple exemple.
! ------...
Kincardine asked 5/6, 2014 at 15:46
2
Solved
I'm trying to create a Spring Boot application where I want to create and use database tables on demand, without defining entities / repositories for them.
I have got a base Business entity, and B...
Hogue asked 29/9, 2019 at 10:35
4
Solved
According to the reference, the name of a non-type template parameter is optional, even when assigning a default value (see (1) and (2)). Therefore these template structs are valid:
template <i...
Oro asked 20/1, 2020 at 14:1
2
Solved
What is the difference between std::invocable and std::regular_invocable? Based on the description from
https://en.cppreference.com/w/cpp/concepts/invocable I would expect that the std::regular_inv...
Carnassial asked 8/11, 2020 at 14:34
3
Solved
Consider a bunch of fundamental types, Foo, all with unique implementations of a common method, Bar(). I can combine Foo1, Foo2, Foo5 like so:
CombinedFoo<Foo1, Foo2, Foo5> combined_foo;
Whi...
Indelicate asked 22/3, 2020 at 6:57
2
Solved
I have the code below. It seems that I can't put an object of class Nonlife that is a superclass of class Vehicle into a container of type Collection<? super Vehicle> ALTHOUGH there is ...
Sieber asked 30/8, 2020 at 8:49
2
Solved
I am learning generic programming in java.
I saw these charts in Core Java (Edition 9):
And I saw these charts in Introduction to Java Programming Comprehensive Version Tenth Edition:
But I beli...
Lyndell asked 30/8, 2020 at 5:26
3
Solved
This example uses a common variadic template and function. I want to print out the arguments passed to f:
#include <iostream>
template <typename T>
void print(T t)
{
std::cout <&l...
Puffball asked 9/9, 2012 at 20:21
1
Solved
I'm trying to write a generic function that takes a Path pointing to a csv file, parses and deserializes the file to a vector of records of a certain type and returns the vector of records.
...
Berm asked 19/6, 2020 at 22:29
4
I'm building a simple 2D game engine, and its getting bigger and bigger, exposing all of the function in Lua will be impossible: so I'm trying to automate a little bit the process,
Is there anyway...
Furmark asked 29/9, 2018 at 1:46
3
Solved
I have a bunch of classes that have one function in common, except that it returns a pointer to their own type. The code looks the same and I would like to move that into an abstract base class. Bu...
Upswing asked 24/8, 2014 at 10:34
2
Solved
So I have a function where, using C++17, I'm able to apply any method from any object:
#include <functional>
template <typename Object, typename Method, typename ... Args>
void ApplyMe...
Proust asked 7/3, 2020 at 8:51
2
Solved
Currently in Electrum we use the Union type on self to be able to access methods from multiple mixed-in parent classes. For example, QtPluginBase relies on being mixed into a subclass of HW_PluginB...
Androecium asked 12/12, 2019 at 20:5
1
I'm trying to understand singleton types in shapeless and faced misunderstanding about singleton types compile-time type. Here is an example:
val x: Witness.`120`.T = 120.narrow
It works fine, b...
Pizor asked 16/12, 2019 at 10:42
1 Next >
© 2022 - 2025 — McMap. All rights reserved.