Skip to main content

All Questions

Tagged with or
14 votes
5 answers
2k views

I implemented FFT in C

I wrote Cooley-Tukey's FFT algorithm in C. And I want to know how safe is this code? Is it just trash? How can I make it more memory safe? ...
RudraSama's user avatar
  • 181
9 votes
2 answers
855 views

My shared_ptr implementation

I would like to ask for a code review of my shared_ptr<T> implementation for design, code style. Any nitpicks will extremely useful for me. The features ...
Quasar's user avatar
  • 639
10 votes
6 answers
2k views

k-Nearest Neighbors algorithm in C

I've been learning C for a while, and I decided to make a simple kNN program. What can I do to improve the program? Am I doing memory management right? Can the structure of the code be improved in ...
Super Tux's user avatar
  • 313
4 votes
1 answer
124 views

Maze game from book Design Patterns with smart pointers and polymorphism

The Design Patterns book chapter 3 about Creational Patterns starts with a maze game. They use the maze as an example throughout the chapter and instead of rooms they have also things like enchanted ...
elehtine's user avatar
  • 165
3 votes
1 answer
120 views

Leveraging EBCO (Empty Base Class Optimization )in a Simplified Smart‐Pointer with Custom Deleters

I’ve been experimenting with a minimal unique_ptr–style class to see Empty Base Class Optimization(EBCO) in action when the deleter is empty: ...
sam's user avatar
  • 379
7 votes
3 answers
1k views

C++ implementation of Go inspired cancellable context

I am trying to create golang inspired cancellable context in C++ for use in worker threads and other tasks. I have tried to avoid using raw pointers, but ever since I started writing C++ code, I ...
Mahdi Chaari's user avatar
4 votes
1 answer
145 views

Compute index in a ring buffer

I have a buffer implemented as a fixed-size std::vector with two begin and end pointers ...
Phil's user avatar
  • 41
14 votes
2 answers
580 views

Custom implementation of `std::unique_ptr<T>`

I skimmed through the documentation on cppreference.com and put down the basic functionalities expected out of a unique_ptr<T> implementation. I coded up a ...
Quasar's user avatar
  • 639
6 votes
2 answers
785 views

polymorphic message container [closed]

Any comments/suggestions on this design? I just want to hold onto an ordered collection of messages. Each message can be one of several types. I'm using some code analogous to this currently in a ...
Taylor's user avatar
  • 303
5 votes
3 answers
410 views

Implementation of arrays that store their size

In this code I implemented arrays that store their own size before the first element. To access it you need to go back exactly sizeof(size_t) bytes back. To free it,...
yurich's user avatar
  • 157
3 votes
2 answers
170 views

Todo List app using C

I just learned to deal with pointers and memory allocation stuff. Using that, I built a todo list app, and it works as far as I tested it. I didn't account for many user errors, so any suggestion to ...
Sarthak Hingankar's user avatar
5 votes
3 answers
907 views

Safe(r) / Easier Pointer Allocation Interface in C (ISO C11)

I spent like half an hour programming up a set of functions to make the allocation / deallocate of pointers easier within a bigger project. I felt that they were satisfactory, but was wondering if ...
Zenais's user avatar
  • 75
1 vote
1 answer
274 views

A unique_ptr-like class, for spans instead of raw pointers

Introduction / Motivation I like the CADRe (a.k.a. RAII) resource management idiom in C++. And I like std::span's; or perhaps I should say, I dislike the use of ...
einpoklum's user avatar
  • 2,099
3 votes
1 answer
107 views

Compare and merge sets from unstructured variables for automatic differentiation

I have developed an automatic differentiation module for my software. Usually AD comes in two forms; forward mode or reverse mode and very clever approaches, beyond me, might mix both. Typically the ...
Attack68's user avatar
  • 633
4 votes
1 answer
187 views

Trie implementation using std::shared_ptr

I've implemented a basic Trie that is supposed to work only with lowercase English letters. ...
csmathhc's user avatar
  • 143

15 30 50 per page
1
2 3 4 5
28