This search loop is too slow. It has computational complexity O(n^2) in the worst case.
You can improve you solution:
1.  Replace std::vector<double> codes by std::set< double > codes;
2.  Write two functions add_to_code that adds to the set and check_code that checks if there is a code in your set and returns bool.
3. Do not store pass value just call check_code with new one.