0

Brace yourselves! C++ newbie question incoming:

Can someone explain to me why this error occurs and how should I fix it?

std::vector<std::string> options = vectorOGROptions_.get() 

I want to get options var as std::vector<std::string> but it seems my vectorOGROptions property returns a different type..

error: conversion from ‘const std::basic_string<char>’ to non-scalar type ‘std::vector<std::basic_string<char> >’ requested 
1
  • Assuming you're using C++03 and not C++11, do std::vector<std::string> options(1, vectorOGROptions_.get());. Commented Nov 15, 2013 at 12:42

3 Answers 3

2

Your get() function returns string, but you are trying to initialize vector with this string, that's not allowed.

You can use something like this

std::vector<std::string> options; options.push_back(vectorOGROptions.get()); 
Sign up to request clarification or add additional context in comments.

Comments

0

You are trying to assign to a vector a string. You cannot do this. Use an initialiser list.

std::vector<std::string> options{vectorOGROptions_.get()}; 

Comments

0

The error says that this get() function returns const std::basic_string<char>, which is nothing but std::string. Use vector's push_back() method:

std::vector<std::string> options; options.push_back(vectorOGROptions_.get()); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.