**tl;dr;** How to reproduce `memset` with basic *c++*?

I am trying to figure out how `memset` works , and to see if I can reproduce it within normal *`c++`* using pointers and address. 

This is what I've got so far. 

```cpp
    void test_memset( void * origin, uint8_t val, size_t size ){
         if( size != 1 ){
             uint8_t* new_or = (uint8_t*) origin;  // casting to uint8_t*
             *new_or ^= (*new_or & 0xff); // clearing any remaining data
             *new_or ^= val;              // assigning the val
             new_or++;                    // incrementing pointer
             test_memset_alloc( new_or, val, size-1 ); // recursion
         }
    }   

```

So the question : **What does memset look like in basic c++?** 

EDIT 1:
-------

Answered [here](https://stackoverflow.com/questions/18851835/create-my-own-memset-function-in-c/18851921#18851921) in similar manner, and [here](https://stackoverflow.com/questions/13327155/memset-definition-and-use) a tad bit more verbose. Both answers are better suited than my proposition.

But i would like to see some detailed solutions, that would be able to explain a Mort (the line-of-business developer) or someone with fractuated knowledge, what is happening with more clarification than :"This is frowned upon" or "not a c++ way".