Questions tagged [generics]
Generic programming is a style of computer programming in which algorithms are written in terms of to-be-specified-later types that are then instantiated when needed for specific types provided as parameters.
                507 questions
            
            
            
                1
            
            vote
        
        
            
                0
            
            answers
        
        
            
                76
            
            views
        
        
        Wrap Ohm.js to provide more type-safety when writing and using semantic adapters
                    Background
I am working on a project to display and manipulate 3D puzzle cubes (e.g. Rubik's Cubes).
As the next step in the project, I want to be able to parse algorithm notation and then execute ...
                
            
       
        
            
                5
            
            votes
        
        
            
                1
            
            answer
        
        
            
                62
            
            views
        
        
            
        Created a Generic Row to do a lot of regular operation easily
                    I create generic Row to handle almost 90 percent of the basic feature.
I need your feedback to make it more flexible and extensible
...
                
            
       
        
            
                1
            
            vote
        
        
            
                0
            
            answers
        
        
            
                70
            
            views
        
        
            
            
        A TypeScript library allowing to call socket.io events like pure functions
                    I'm creating a Typescript library (full repository here) whose goal is to be able to call socket.io events as regular functions:
Server side demo:
...
                
            
       
        
            
                1
            
            vote
        
        
            
                0
            
            answers
        
        
            
                89
            
            views
        
        
            
            
        Generic sync.Map in Go
                    In one of our projects it became rather painful to use the Go standard library's sync.Map as it lacks type safety, i.e. it became rather tedious to do and check ...
                
            
       
        
            
                7
            
            votes
        
        
            
                1
            
            answer
        
        
            
                312
            
            views
        
        
            
            
            
        Errors as values and Generic Option, Result types in C++
                    I wanted to get an in-depth view of both Templates and Concepts in C++, so I made this library. https://github.com/Hernanatn/errores--
I'd like to ask:
is this a proper use of concepts?
is the code ...
                
            
       
        
            
                6
            
            votes
        
        
            
                1
            
            answer
        
        
            
                234
            
            views
        
        
            
        A generic function that reads a line of numeric values from a file
                    I'm writing a library of IO functions for my physics laboratory class. In the meanwhile, I'm hoping to learn more about generic programming and C++20 concepts.
Some context
I usually came home from ...
                
            
       
        
            
                5
            
            votes
        
        
            
                2
            
            answers
        
        
            
                543
            
            views
        
        
            
            
        Second Try at C++ 20 Generic Dictionary for enums and Strings
                    This is a follow up question to Abstract Generic Dictionary. Some of the code reviewed in this question was also reviewed in C++20 Performance Test Code Generator.
The new template class attempts to ...
                
            
       
        
            
                5
            
            votes
        
        
            
                1
            
            answer
        
        
            
                175
            
            views
        
        
            
            
            
        ConverterService: type conversion multitool
                    I got sick and tired of type-related errors and decided to write a type conversion service
It's not particularly pretty what with those casts and suppressions, but it seems to do what it was designed ...
                
            
       
        
            
                4
            
            votes
        
        
            
                2
            
            answers
        
        
            
                147
            
            views
        
        
            
            
            
        Generic ring-buffer
                    What would be the preferred C way of implementing a simple generic ring-buffer.
Which approach from the 2 below (or even some 3rd) would you use and why?
Specifically, this will be part of an embedded ...
                
            
       
        
            
                9
            
            votes
        
        
            
                4
            
            answers
        
        
            
                1k
            
            views
        
        
            
            
            
        Generic C++ Class to Associate enum Values with Strings for Translation
                    This is the first time I am using C++ templates in a very long time, and is the first time I have created a template class.
When developing projects I often run into a common problem: I have an enum ...
                
            
       
        
            
                2
            
            votes
        
        
            
                1
            
            answer
        
        
            
                56
            
            views
        
        
            
            
        Dispatching generic calls and types in TypeScript
                    This is an expanded version of my question at SO: https://stackoverflow.com/questions/78929495/typescript-conditional-type-does-not-accept-value-even-when-all-branches-do 
This is not real code (yes, ...
                
            
       
        
            
                4
            
            votes
        
        
            
                3
            
            answers
        
        
            
                373
            
            views
        
        
            
            
            
        Type Traits for C with _Generic
                    Motivation:
Type traits are useful in defining robust function-like macros. Code below has:
IS_COMPATIBLE(EXPR, T)
IS_NULLPTR(T)...
                
            
       
        
            
                6
            
            votes
        
        
            
                3
            
            answers
        
        
            
                225
            
            views
        
        
            
            
            
        An Attempt at Creating a Type-Safe, Generic Swap Macro With Compile Time Error Checking
                    Properties:
It evaluates each of A and B only once (sizeof is special, as it doesn't ...
                
            
       
        
            
                1
            
            vote
        
        
            
                1
            
            answer
        
        
            
                115
            
            views
        
        
            
            
            
        Generic Min() for Integer Types (including Boolean)
                    This is a follow-up to Generic Max() for Integer Types (including Boolean) and An Attempt at Creating Generic Min()/Max() for Fundamental Types.
What's new:
MIN(), ...
                
            
       
        
            
                8
            
            votes
        
        
            
                2
            
            answers
        
        
            
                264
            
            views
        
        
            
            
            
        Generic Max() for Integer Types (including Boolean)
                    This is a follow-up to An Attempt at Creating Generic min()/max() for Fundamental Types.
What's Changed:
MIN() has been forsaken for the time being.
Mixed types ...
                
            
       
         
         
        