Problem:
- Many constructors are defined as `{}` rather than using the ` =
default` compiler-provided constructor.
- Some types provide an implicit conversion operator from `nullptr_t`
instead of requiring the caller to default construct. This violates
the C++ Core Guidelines suggestion to declare single-argument
constructors explicit
(https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit).
Solution:
- Change default constructors to use the compiler-provided default
constructor.
- Remove implicit conversion operators from `nullptr_t` and change
usage to enforce type consistency without conversion.
Problem:
- We were using some incorrect format strings in printf-functions:
* "%7lu" to print `size_t` values instead of "%7zu";
* "%7i" to print `unsigned int` values instead of "%7u".
Solution:
- Use out(), outln() and warnln() instead of printf-functions. :^)
`unsigned int` -> `unsigned`.
Use brace initialisers instead of equal initialisers for struct members.
Prefix global variables with `g_`.
Wrap multi-line statements in curly braces.
Also:
Use const references instead of references when possible.
Rename `file_name` to `file_specifier`: "-" is not a file name.
Rename `files` to `file_specifiers`.
Avoid some useless checks.
This reverts commit 0ae9ae48fa.
@bcoles informs me that these match Solaris 9 and it checks out.
I don't know what version I was comparing against, and who cares?
The vast majority of programs don't ever need to use sys$ptrace(),
and it seems like a high-value system call to prevent a compromised
process from using.
This patch moves sys$ptrace() from the "proc" promise to its own,
new "ptrace" promise and updates the affected apps.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
The modifications in this commit were automatically made using the
following command:
find . -name '*.h' -exec sed -i -E 's/dbg\(\) << ("[^"{]*");/dbgln\(\1\);/' {} \;
- Store history entries as (timestamp)::(entry)\n\n
- Merge the entries together when saving to avoid loss of history
entries
To ideally make having two concurrently open shells
(or `js` repls or whatever) not overwrite each others' history entries.
Problem:
- The implementation of `find` is coupled to the implementation of
`SinglyLinkedList`.
Solution:
- Decouple the implementation of `find` from the class by using a
generic `find` algorithm.
Problem:
- The implementation of `find` is coupled to the implementation of
`DoublyLinkedList`.
- `append` and `prepend` are implemented multiple times so that
r-value references can be moved from into the new node. This is
probably not called very often because a pr-value or x-value needs
to be used here.
Solution:
- Decouple the implementation of `find` from the class by using a
generic `find` algorithm.
- Make `append` and `prepend` be function templates so that they can
have binding references which can be forwarded.
Problem:
- The implementation of `find` is coupled to the implementation of `Vector`.
- `Vector::find` takes the predicate by value which might be expensive.
Solution:
- Decouple the implementation of `find` from `Vector` by using a
generic `find` algorithm.
- Change the name of `find` with a predicate to `find_if` so that a
binding reference can be used and the predicate can be forwarded to
avoid copies.
- Change all the `find(pred)` call sites to use `find_if`.
Problem:
- `find` is implemented inside of each container. This coupling
requires that each container needs to individually provide `find`.
Solution:
- Decouple the `find` functionality from the container. This allows
provides a `find` algorithm which can work with all
containers. Containers can still provide their own `find` in the
case where it can be optimized.
- This also allows for searching sub-ranges of a container rather than
the entire container as some of the container-specific member
functions enforced.
Note:
- @davidstone's talk from 2015 C++Now conference entitled "Functions
Want to be Free" encourages this style:
(https://www.youtube.com/watch?v=_lVlC0xzXDc), but it does come at
the cost of composability.
- A logical follow-on to this is to provide a mechanism to use a
short-hand function which automatically searches the entire
container. This could automatically use the container-provided
version if available so that functions which provide their own
optimized version get the benefit.