Updated FAQ (markdown)

Howard Hinnant
2019-12-12 14:50:56 -08:00
parent 708329b85f
commit ef02185788

8
FAQ.md

@@ -54,6 +54,14 @@ The syntax is slightly more verbose in that you have to explicitly convert the `
2 conversions. Roughly twice as fast! And the code generation (using clang++ -O3) is roughly half the size: 152 assembly statements vs 335 assembly statements.
Finally, one can take advantage of the fact that the conversion from `sys_days` to `year_month_day` can be made implicitly, and so one can further simplify the syntax (this change does not impact code generation):
year_month_day
get_meeting_date(year y, month m)
{
return sys_days{Tuesday[3]/m/y} + days{1};
}
This philosophy is similar to that which we have for containers: It would be super easy to create `vector<T>::push_front(const T&)`. But that would make it too easy for programmers to write inefficient code. The compiler helps remind the programmer that perhaps `deque<T>` or `list<T>` would be a better choice when he attempts to code with `vector<T>::push_front(const T&)`.
It would be very easy to add `T& list<T>::operator[](size_t index)`. But that would encourage the programmer to use `list<T>` when a random-access container would probably be more appropriate for the task.