If "better solutions" demoralize you, don't
ever go to Boost's website. Anyway. I notice that you tagged this
c++11, which sets you well ahead of most beginners already. If you want some competent advice on a working piece of your code, you can post a question on
Code Review. StackOverflow here is for code that doesn't work, so people can help you spot the problem. Beware to make it a
good question though, have a look around to know what to do and not to do. Welcome to the Stack ! —
Quentin 23 secs ago