Bubble sort implementation in C++
Implementation

size - sorted_elements might not return what you expect if size == 0 (it returns std::numeric_limits&lt;unsigned int&gt;::max()). This makes the intended check fail for size == 0. This can be fixed by changing the while loops condition to sorted_elements &lt; size &amp;&amp; !sorted.
You could use std::swap(arr[index], arr[index + 1]); to swap the elements. This way, the preferred assignment operation (copy or move) for Element will be used (if Element provides its own specialization). Currently, you always copy, which might not always be preferred (e.g. with large std::strings).