To check whether a given number has been computed previously or not
You could use a hashtable to keep track of all values you've seen before.  (You could also use a balanced binary tree data structure, but it will probably be less efficient in practice, due to the overhead of the pointer traversals.)

If you don't mind occasional false positives, you could use a Bloom filter, and that might be even more efficient -- at the cost of occasionally declaring "I've seen this number before!" when you actually haven't.

Questions about specific C++ libraries are off-topic here but can be asked on Stack Overflow once you know what data structure you want to use.