Dobiasd / FunctionalPlus

Functional Programming Library for C++. Write concise and readable C++ code.
http://www.editgym.com/fplus-api-search/
Boost Software License 1.0
2.1k stars 167 forks source link

Clang 16: incompatible initializer of type (container_common_test) #273

Closed offa closed 1 year ago

offa commented 1 year ago

Compilation of container_common_test.cpp fails on Clang 16:

 /__w/FunctionalPlus/FunctionalPlus/test/container_common_test.cpp:664:16: error: variable 'f' with type 'const auto' has incompatible initializer of type '<overloaded function type>'
    const auto f = floor<double>;
               ^   ~~~~~~~~~~~~~

Full build log is available on Clang 16 PR (#274).

Dobiasd commented 1 year ago

Oh, interesting! :monocle_face:

floor is defined as follows:

template <typename X, typename Out = int>
Out floor(X x)

(and only once in namespace fplus)

So, I guess, overloaded function type means there is some other function with the same name.

Would it help to change from

const auto f = floor<double>

to

const auto f = fplus::floor<double>

?

In case it does not help, maybe explicitly set the Out type like so:

const auto f = floor<double, int>

Would you like to test in the Clang 16 CI build MR or shall I?

offa commented 1 year ago

Adding fplus:: seems to do the trick, PR updated :+1:

Dobiasd commented 1 year ago

Yay! :tada:

Thanks. :+1: