Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
19 votes

strcat_new() function, not present in standard C library

Neat and well formatted Design Rather than "then after every string, the 'delim' string is concatenated." (that sounds like n delimiters), I would expect ...
chux - Reinstate Monica's user avatar
18 votes
Accepted

Min function accepting varying number of arguments in C++17

template <typename Less, typename T, typename... Ts> constexpr const T& min(Less less, const T& a, const T& b, const Ts&... rems) { This ...
Snowhawk's user avatar
  • 6,148
17 votes
Accepted

Implementation of C Standard Library Function ntohl()

Unless you wish to optimize the code, with specialized swappers for various hosts orders, you are doing it wrong. I invite you to check The Byte Order Fallacy by Rob Pike. The punch line: the byte ...
Matthieu M.'s user avatar
  • 5,137
16 votes

2D counterpart of std::array in C++17

Let me collect a couple of thoughts here. Aggregate initialization currently works like this: array2d<int, 2, 2> a{{1, 2, 3, 4}}; but wouldn't it be ...
lubgr's user avatar
  • 956
14 votes
Accepted

Java TreeMap.floorKey() equivalent for std::map

Headers and namespaces The function is missing a definition of map. This is probably what you want: ...
Toby Speight's user avatar
  • 75.7k
12 votes

Min function accepting varying number of arguments in C++17

This looks nice! Two issues I see here, When compiling your template with clang, it refuses the if constexpr dispatch for every ...
lubgr's user avatar
  • 956
12 votes
Accepted

Linked List implementation in c++ with all functions

Using std::shared_ptr to manage your nodes is very heavyweight. I would expect a container to look for efficiency, or provide seriously extended service. ...
Deduplicator's user avatar
  • 19.3k
11 votes
Accepted

A library for interacting with JPL Horizons

Use Requests urllib is kind of a pain to use. Use Requests instead. Among other things, all of this code: ...
Reinderien's user avatar
  • 62.1k
9 votes
Accepted

NASM tutorial (Linux syscalls, 64 bit) code with CI-build and test

When the function has finished it's logic, these registers should have their previous values The normal x86-64 System V calling convention allows functions to clobber RAX, RCX, RDX, RSI, RDI, and R8-...
Peter Cordes's user avatar
  • 3,346
9 votes

Min function accepting varying number of arguments in C++17

It works well, according to my simple test program: #include <functional> int main() { return min(std::less<int>(), 2, 0, 3); } I suggest that when ...
Toby Speight's user avatar
  • 75.7k
9 votes

Java TreeMap.floorKey() equivalent for std::map

Your code is obviously wrong: template <typename key,typename value> This line suggests that the code works for arbitrary maps, yet you require an ...
Roland Illig's user avatar
  • 21.3k
9 votes

strcat_new() function, not present in standard C library

Reserved identifiers The include-guard _STRCAT_NEW_H_ is one of the names reserved for the implementation, as it begins with underscore and an upper-case letter. As ...
Toby Speight's user avatar
  • 75.7k
9 votes

C++ I wrote a simple and fast formatting library for strings

This library is not the best in general, but for my project needs it is the fastest and the best Did you run any benchmarks? How does it compare against iostream, ...
G. Sliepen's user avatar
  • 56.8k
8 votes
Accepted

MMMRjs a product of BYTES Genesis

Comments The comments such a This is Mean. are pointless. And the comment ...
RoToRa's user avatar
  • 11k
8 votes
Accepted

Generic matrix library in Java

Dense matrix multiplication in 15572 ms. Going by the demo code I assume this was the product between two 1000x1000 matrices. By my estimate based on old code the raw operations by themselves could ...
user555045's user avatar
  • 9,794
7 votes

Implementation of C Standard Library Function ntohl()

To properly check the byte order, you must check it using uint32_t, since on the PDP-11 the value 0x01020304 was stored as ...
Roland Illig's user avatar
  • 21.3k
7 votes
Accepted

Wrapping libusb library in C++

It is kind of hard to say without seeing the whole code but at a glance the whole thing seems kind of pointless to me. You're not making it object oriented but rather just adding your own "flavor" API ...
Emily L.'s user avatar
  • 16.6k
7 votes
Accepted

My little C++ library for comfortable programming

General Observations Can it be done in other way? For example, I can write code in multiple files, but then compile into one .lib file? If so, how to install it then? Generally it is best to put ...
pacmaninbw's user avatar
  • 23.8k
7 votes

C++ I wrote a simple and fast formatting library for strings

DSL design Think about the DSL you want to implement, write its rules down, and then try to find the corner-cases. What should happen if the string in the smart-padding is bigger than the requested ...
Deduplicator's user avatar
  • 19.3k
7 votes

C++ (Cross-Platform) Predefined Library

Design review There are other libraries that do more or less what you’re trying to do, in whole or in part (for example Boost.Config). Even so, I’m skeptical about why most of this stuff would be ...
indi's user avatar
  • 11.3k
7 votes

Arduino library to simplify differential drive robots

General Observations The point of a library is to provide abstraction, reducing the amount of work that the user needs to do to accomplish what they want to do. This library does not provide any ...
pacmaninbw's user avatar
  • 23.8k
7 votes
Accepted

Arduino library to simplify differential drive robots

It's great that you have a library that works for you, but now you should think of redesigning it. I see that class DDBot is implementing the low-level ...
G. Sliepen's user avatar
  • 56.8k
7 votes

A simple unit test library for C

The header doesn't need to include anything except <stddef.h> (to define size_t). These two externs are never used: <...
Toby Speight's user avatar
  • 75.7k
6 votes
Accepted

value_ptr<T> - a C++11 header-only, deep-copying smart pointer that preserves value semantics for polymorphic and undefined types

Scanning your description: The idea of this value_ptr sounds perfectly reasonable. You have a pointer to a polymorphic object, and then you want to be able to make ...
Quuxplusone's user avatar
  • 19.4k
6 votes
Accepted

Function declarations using macros to support multiple platforms

Keep the DLLExport macro on all platforms, but make the definition resolve to nothing unless you're on Windows. You might also want to rename the macro to something more neutral. Something like this: ...
rjnilsson's user avatar
  • 1,651
6 votes

Initialized Array Template Class (C++)

Now that you know the Rule of Three, and have been pointed by 1201ProgramAlarm to study the Rule of Five... you should also be aware of the Rule of Zero. Try rewriting your code to eliminate all ...
Quuxplusone's user avatar
  • 19.4k
6 votes

MMMRjs a product of BYTES Genesis

Rotara already mentioned some great points - the comments can definitely be improved and follow common conventions, sorting should happen on copies of the data instead of the original data, and the ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
6 votes
Accepted

Frame Strings that contain newlines

First of all, the solution is sound and rather well-structured. So, take my comments as hints towards production-quality coding. Class structure The algorithm for framing is in a class named ...
Ralf Kleberhoff's user avatar
6 votes

Thread-safe strtok in C - version II

Reconsider token_t This is currently a linear linked list of tokens, surprising given the name. A strictly-evaluated linear linked list isn’t an efficient data ...
Davislor's user avatar
  • 7,536

Only top scored, non community-wiki answers of a minimum length are eligible