lundi 27 novembre 2017

trying to generate all sub-sequences of string vector using unique pointers

std::unique_ptr<std::vector<std::string>> generate_all_subsequences(const std::string & sequence)
{
const int n = sequence.size();
//const std::string order(sequence);

std::unique_ptr<std::vector<std::string>> subsequences(new std::vector<std::string>);
int num = pow(2, n);

 for(int i = 0; i<= num-1; i++)
     {
       std::unique_ptr<std::string> candidate(new std::string);
       for(int j = 0; j<= n-1; j++)
         {
           if(((i >> j) & 1) == 1)
             {
                 candidate->push_back(sequence[j]);
             }

         }
         subsequences->push_back(candidate);//error in this line
     }
   return subsequences;
}

error: no matching function for call to 'std::vector >::push_back(std::unique_ptr >&)' 6 mins

Aucun commentaire:

Enregistrer un commentaire