Simple data structures--Arne Mertz
Keep it simple!
Simple data structures
by Arne Mertz
From the article:
Keep simple data structures simple! There’s no need for artificial pseudo-encapsulation when all you have is a bunch of data...
March 19-21, Madrid, Spain
April 1-4, Bristol, UK
June 16-21, Sofia, Bulgaria
By Adrien Hamelin | Dec 20, 2018 02:19 PM | Tags: basics
Keep it simple!
Simple data structures
by Arne Mertz
From the article:
Keep simple data structures simple! There’s no need for artificial pseudo-encapsulation when all you have is a bunch of data...
By Meeting C++ | Nov 30, 2018 04:15 AM | Tags: performance meetingcpp intermediate experimental efficiency community c++17 c++14 c++11 basics advanced
Pictures and more about Meeting C++ 2018!
Meeting C++ 2018 wrap up
by Jens Weller
From the article:
Two weeks ago, Meeting C++ 2018 started. The first attendees got their badges and it was again this time of year for my staff, the volunteers and myself: conference time...
By Adrien Hamelin | Nov 29, 2018 01:36 PM | Tags: community basics
Agree with the logic?
How to Design Function Parameters That Make Interfaces Easier to Use (2/3)
by Jonathan Boccara
From the article:
Let’s continue exploring how to design function parameters that help make both interfaces and their calling code more expressive.
If you missed on the previous episode of this topic, here is what this series of articles contains:
- Part 1: interface-level parameters, one-parameter functions, const parameters,
- Part 2: calling contexts, strong types, parameters order,
- Part 3: packing parameters, processes, levels of abstraction.
By Adrien Hamelin | Nov 27, 2018 02:10 PM | Tags: basics
Quick A: The returned variable can be modified.
Recently on SO:
What does it mean to return a reference?
It means you return by reference, which is, at least in this case, probably not desired. It basically means the returned value is an alias to whatever you returned from the function. Unless it's a persistent object it's illegal.
For example:
int& foo () { static int x = 0; return x; } //... int main() { foo() = 2; cout << foo(); }would be legal and print out 2, because foo() = 2 modifies the actual value returned by foo.
However:
int& doit () { int x = 0; return x; }would be illegal (well, accessing the returned value would), because x is destroyed when the method exits, so you'd be left with a dangling reference.
Returning by reference isn't common for free functions, but it is for methods returning members. For example, in the std, the operator [] for common containers return by reference. For example, accessing a vector's elements with [i] returns an actual reference to that element, so v[i] = x actually changes that element.
Also, I hope that "is essentially equal to this code" means that they're semantically sort of (but not really) similar. Nothing more.
By Adrien Hamelin | Nov 12, 2018 01:23 PM | Tags: basics
Simple.
How to Retrieve the Firsts from a Collection of Pairs
by Jonathan Boccara
From the article:
When using the STL, there is a use case that pops up every now and then and that often causes more trouble than necessary: if we have a collection of pairs, like an std::vector of pairs, or simply a std::map, how can we retrieve the collection of the first elements of each item in the collection?
By Adrien Hamelin | Oct 15, 2018 12:27 PM | Tags: c++11 basics
Quick A: The unordered_* containers have average O(1) complexity.
Recently on SO:
data structure with O(1) search time complexity in c++
What you want is C++11's std::unordered_map, with an average access time of O(1) and a worst case of O(n).
By Adrien Hamelin | Sep 18, 2018 12:31 PM | Tags: basics
Using the std to remove.
How to Remove Elements from a Sequence Container in C++
by Jonathan Boccara
From the article:
As part of the STL Learning Resource, we’re tackling today the STL algorithms that remove elements from a collection.
Removing an element from a C++ collection can’t be that complicated, can it?
Well, how can I put it… It has a rich complexity, let’s say.
Ok, maybe it’s a little complicated.
We will cover this topic in a series of four articles:
- How to Remove Elements from a Sequence Container (vector, string, deque, list)
- How to Remove Pointers from a Vector in C++ (co-written with Gaurav Sehgal)
- How to Remove Elements from an Associative Container (maps and sets)
- How to Remove Duplicates from an Associative Container
By Adrien Hamelin | Sep 3, 2018 08:03 AM | Tags: basics
Quick A: yes
Recently on SO:
Is 'auto const' and 'const auto' the same?
The const qualifier applies to the type to the immediate left unless there is nothing to the left then it applies to the type to the immediate right. So yup it's the same.
By Jason Turner | Jul 23, 2018 10:31 AM | Tags: performance efficiency basics
Episode 125 of C++ Weekly.
The Optimal Way To Return From A Function
by Jason Turner
About the show:
In this episode of C++ Weekly Jason investigates the possible methods that one of two string values might be returned from a function. Which option is best? Which option can the compiler optimize the most? Do we take one return path or multiple return paths? Should a ternary be used?
By Jordi Mon Companys | Jul 9, 2018 01:43 PM | Tags: community basics
Alberto García Márquez will guide us through his lib Calculate and we will also elaborate on the use of some clang tools for refactoring, code format and so on at an entry level.
C++ Meetup Madrid: Calculate: Math Expression Parser Engine
Come join us!