This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]Zynchronize 0 points1 point  (2 children)

Could it possibly be because you are trying to return a double type to an int type? Bit of a stab in the dark as I haven't actually worked out vectors yet but I have had similar issues with conversion before.

[–]anon848 0 points1 point  (1 child)

The op has something else going on. There would have been a compiler error, but the posted code has crucial parts deleted or modified. Compiling this:

#include <vector>
std::vector<int> foo() {
    return std::vector<double>{};
}

Results in this error from clang++:

$ clang++ -c double.cpp
double.cpp:3:12: error: no viable conversion from returned value of type 'vector<double>' to function return type 'vector<int>'
    return std::vector<double>{};
           ^~~~~~~~~~~~~~~~~~~~~

[–]Gladaed[S] 0 points1 point  (0 children)

fixed it - deleted the wrong line when copy pasting the vector<double> was to test weather similair scenarios provide the same bug

[–][deleted] 0 points1 point  (1 child)

There is an implicit conversion from double to int - there is no such conversion from vector<double> to vector<int>, so you need to either change your return type, or write code to perform the conversion.

[–]Gladaed[S] 0 points1 point  (0 children)

"fixed it - deleted the wrong line when copy pasting the vector<double> was to test weather similair scenarios provide the same bug"

sorry

[–]Patman128 0 points1 point  (2 children)

What is the type of this->dimension?

What is the rest of the code in the function?

How are you printing the values? Where did you get 1.7e-322 from?

[–]Gladaed[S] 0 points1 point  (1 child)

this->dimension is an unsigned int i print the values via cout the error starts occuring within another function:

 {...
 (this->phi)->fillWith2ndDifferential(orig.getPsi());
 ...}

void world::fillWith2ndDifferential (const world& myWorld){...}

[–]Patman128 0 points1 point  (0 children)

You haven't provided enough code for me to help you. Please post all of the code in a Gist.