Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot convert from 'initializer list' to 'toppra::BoundaryCond' #245

Open
maxpla3 opened this issue Jan 11, 2024 · 0 comments
Open

Cannot convert from 'initializer list' to 'toppra::BoundaryCond' #245

maxpla3 opened this issue Jan 11, 2024 · 0 comments

Comments

@maxpla3
Copy link

maxpla3 commented Jan 11, 2024

While compiling the project in VS Studio 2022 I get following error:
error C2440: 'initializing': cannot convert from 'initializer list' to 'toppra::BoundaryCond'

5>C:\Users\Default\git\ToppRaMinimal\toppra\toppra\cpp\tests\test_cubic_spline.cpp(79,18): error C2440: 'initializing': cannot convert from 'initializer list' to 'toppra::BoundaryCond'
5>C:\Users\Default\git\ToppRaMinimal\toppra\toppra\cpp\tests\test_cubic_spline.cpp(79,18): message : 'toppra::BoundaryCond::BoundaryCond': ambiguous call to overloaded function
5>C:\Users\Default\git\ToppRaMinimal\toppra\toppra\cpp\src\toppra/geometric_path/piecewise_poly_path.hpp(23,3): message : could be 'toppra::BoundaryCond::BoundaryCond(int,const toppra::Vector)'
5>C:\Users\Default\git\ToppRaMinimal\toppra\toppra\cpp\src\toppra/geometric_path/piecewise_poly_path.hpp(21,3): message : or       'toppra::BoundaryCond::BoundaryCond(int,const std::vector<toppra::value_type,std::allocator<toppra::value_type>> &)'
5>C:\Users\Default\git\ToppRaMinimal\toppra\toppra\cpp\tests\test_cubic_spline.cpp(79,18): message : while trying to match the argument list '(int, initializer list)'
5>C:\Users\Default\git\ToppRaMinimal\toppra\toppra\cpp\tests\test_cubic_spline.cpp(95,18): error C2440: 'initializing': cannot convert from 'initializer list' to 'toppra::BoundaryCond'
5>C:\Users\Default\git\ToppRaMinimal\toppra\toppra\cpp\tests\test_cubic_spline.cpp(95,18): message : 'toppra::BoundaryCond::BoundaryCond': ambiguous call to overloaded function
5>C:\Users\Default\git\ToppRaMinimal\toppra\toppra\cpp\src\toppra/geometric_path/piecewise_poly_path.hpp(23,3): message : could be 'toppra::BoundaryCond::BoundaryCond(int,const toppra::Vector)'
5>C:\Users\Default\git\ToppRaMinimal\toppra\toppra\cpp\src\toppra/geometric_path/piecewise_poly_path.hpp(21,3): message : or       'toppra::BoundaryCond::BoundaryCond(int,const std::vector<toppra::value_type,std::allocator<toppra::value_type>> &)'
5>C:\Users\Default\git\ToppRaMinimal\toppra\toppra\cpp\tests\test_cubic_spline.cpp(95,18): message : while trying to match the argument list '(int, initializer list)'
...

In piecewise_poly_path.hpp we have:

  BoundaryCond(int order, const std::vector<value_type> &values);  
  BoundaryCond(int order, const Vector values);

The compiler does not know which constructor to use when calling e.g. BoundaryCond bc{1, {0, 0, 0, 0, 0, 0}};.
I think this is because std::vector and toppra::Vector both support initializer lists so the compiler cannot decide which type it has to use.

Solution: Explicitly declare std::vector<value_type> before the initializer list in the constructor call like this: BoundaryCond{3, std::vector<value_type>{1.52, 7.21, 9.31, 2.52, 4.41, 5.54}}

mskripnik added a commit to mskripnik/toppra that referenced this issue Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant