Implement a class template split_bitstring in the namespace cds::algo within the file /app/split_bitstring.h. This class should provide functionality to cut a given bitstring represented by an integer type into smaller parts.
Requirements:
Template Parameters: The class should be templated to accept:
A primary unsigned integer type ValueType (e.g., uint32_t, uint64_t).
An optional secondary unsigned integer type PartUInt for smaller parts, defaulting to uint8_t.
Constructor: Implement a constructor that initializes the splitter with the source bitstring.
Cut Functionality:
Implement a method cut(size_t bits) that:
Returns 0 if there are no bits left to cut (end-of-stream).
Cuts a specified number of bits from the current position and returns the value of those bits, taking into account the byte order (big-endian or little-endian).
Implement a method safe_cut(size_t bits) that should work similarly to cut, but ensures safety bounds by not returning more bits than are available.
End-of-Stream Check: Implement a method bool eos() that returns true if all bits have been cut, otherwise returns false.
Reset Functionality: Implement a method reset() that resets the splitter, allowing it to cut the bitstring from the beginning again.
Byte Order Handling: Include internal logic to handle both big-endian and little-endian byte orders, determining the order based on the system architecture when the object is instantiated.
Implementation Details:
Make sure to include appropriate unit tests that verify:
Cutting of the entire bitstring.
Cutting by hex digit (4 bits) and individual bits.
Random cuts ensuring accumulation of value works correctly.
Ensure the class is efficiently managing internal state and memory.
Reference the provided test code to ensure that all functionality and edge cases are covered during your implementation.