Search found 190 matches
- July 2nd, 2018, 6:33 pm
- Forum: Everything
- Topic: Purify Thyself
- Replies: 2
- Views: 1377
Purify Thyself
All programmers should strive to use pure functions as much as possible. Input goes in as parameters, output goes out as the return value. The function should do nothing else but. int function ( const int input ) { return input * 2; // output } It's simple, elegant, clear, concise and more important...
- June 29th, 2018, 1:03 am
- Forum: Everything
- Topic: Custom Allocator Adventures!
- Replies: 3
- Views: 1602
Re: Custom Allocator Adventures!
Well that's not entirely true. <new> does allocate pages from the OS but it doesn't do it for every allocation. Pages are huge. I believe Windows can only allocate pages that are a multiple of 512 bytes. So you will get pages that are 1024 bytes, 1536 bytes, 2048 bytes etc. 512 bytes alone can fit 1...
- June 26th, 2018, 3:06 pm
- Forum: Everything
- Topic: Custom Allocator Adventures!
- Replies: 3
- Views: 1602
Re: Custom Allocator Adventures!
Since most of you probably won't go through the trouble of benchmarking a program, I'll post my results on the benchmark between using push_back() with reserved memory and just plain push_back(). This'll allow me to talk more about this issue that people on the internet have been arguing about for d...
- June 26th, 2018, 1:24 pm
- Forum: Everything
- Topic: Custom Allocator Adventures!
- Replies: 3
- Views: 1602
Custom Allocator Adventures!
Custom allocators are used quite often in game development. Game developers like to use <new> a lot since they rely heavily on polymorphism. <new> unfortunately is not optimised to allocate individual objects at a time. It's designed for allocating objects in bulk like in std::vector. As a result, g...
- June 21st, 2018, 8:14 am
- Forum: Everything
- Topic: Cache aware allocator
- Replies: 8
- Views: 2583
Re: Cache aware allocator
Thought you were referring to my repository code and I got confused because I was pretty sure I checked to see if it ran before uploading it. Yeah that's just a slight mistake and I've already rectified it. My work has finally allowed me to dive into C++17 and I'm discovering all sorts of crazy feat...
- June 21st, 2018, 7:13 am
- Forum: Everything
- Topic: Cache aware allocator
- Replies: 8
- Views: 2583
Re: Cache aware allocator
I've updated the repository to test this. See for yourself if it works properly
- June 21st, 2018, 6:48 am
- Forum: Everything
- Topic: Cache aware allocator
- Replies: 8
- Views: 2583
Re: Cache aware allocator
Just wanted to update this post saying that Visual Studio 2017 suports C++17's new dynamic allocation for over-aligned types. new(), delete() and std::allocator allocates objects in accordance to their specified alignment. All you have to do is create a struct that's specified to align to the cache ...
- June 19th, 2018, 6:33 pm
- Forum: Everything
- Topic: A New Way to Create Singletons
- Replies: 1
- Views: 983
A New Way to Create Singletons
C++17 has introduced inline variables into the standard. inline for variables works the same for functions; it makes it such that something can be defined multiple times. This allows you to define functions in headers where they will be #include(d) multiple times. Without inline, these multiple #inc...
- June 19th, 2018, 3:52 am
- Forum: Everything
- Topic: Value vs Reference
- Replies: 8
- Views: 7270
Value vs Reference
For millennia, noobs all over the world have debated with themselves whether or not they should prefer to pass by value or pass by reference. The common concensus is to pass by value for basic types like ints and floats but also to pass by reference for structs. Today, we're going to test how true t...
- May 5th, 2018, 6:02 am
- Forum: Everything
- Topic: How to multithread like a pro!
- Replies: 5
- Views: 2182
Re: How to multithread like a pro!
It's been almost a month since I've made this post and needless to say, I've been quite sidetracked these past few weeks. I wanted to come up with a program that I can benchmark to see how much of a benefit it's getting from multithreading but the more and more tests I made, the more ways I realise ...