[boost][mp11][GIL]

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[boost][mp11][GIL]

Boost - Users mailing list
Hi,
I am trying to implement a histogram class that will be able to store tuples of any data type. Most likely, I chose std::tuple for the job. So, in brief I used std::tuple as the key type in an unordered_map. I used boost::hash_value to supply the hasher in place of std::hash in the third template argument to unordered_map.
Now, fast forwarding to my problem, I want to be able to provide a sub-histogram based on a few axes of the histogram. The code below, quite similar to what I want, refuses to work with msvc-14.0 (coming to it shortly).

----Sample Code----
#include <boost/mp11.hpp>
template<typename... T>
struct histogram {
    using type_list = boost::mp11::mp_list<T...>;
    template<std::size_t... D>
    void d() {
        // Error in below line
        histogram<boost::mp11::mp_at_c<type_list, D>...> f;
    }
};
int main() {
    histogram<int, int, int, int> f;
    f.d<1,2>();
    return 0;
}
---END---

So, msvc-14.0 gives the error (after tracing to the last function call in stack) at the position specified above. The error message which is coming from the AppVeyor logs (since I do not have msvc-14.0)
...
C:\projects\boost-root\boost/mp11/utility.hpp(53): error C2971: 'boost::mp11::detail::mp_if_c_impl': template parameter 'C': 'C': a variable with non-static storage duration cannot be used as a non-type argument
C:\projects\boost-root\boost/mp11/utility.hpp(38): note: see declaration of 'boost::mp11::detail::mp_if_c_impl'
C:\projects\boost-root\boost/gil/histogram.hpp(247): note: see declaration of 'C'
...

I am not sure if the issue is with mp11 or the msvc-14.0, but I did find some references which claim a similar issue with the latter case.
This links to a very similar case of the error C2971 which seems to be fixed in the future releases. Also, the code above compiles fine with GCC and Clang.
Any comments or suggestions on this are most welcome.
Thanks, Deb
GSOC 2020 student in Boost.GIL

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [boost][mp11][GIL]

Boost - Users mailing list
On Thu, 18 Jun 2020 at 19:10, Debabrata Mandal via Boost-users
<[hidden email]> wrote:

>
> Now, fast forwarding to my problem, I want to be able to provide a sub-histogram based on a few axes of the histogram. The code below, quite similar to what I want, refuses to work with msvc-14.0 (coming to it shortly).
>
> ----Sample Code----
> #include <boost/mp11.hpp>
> template<typename... T>
> struct histogram {
>     using type_list = boost::mp11::mp_list<T...>;
>     template<std::size_t... D>
>     void d() {
>         // Error in below line
>         histogram<boost::mp11::mp_at_c<type_list, D>...> f;
>     }
> };
> int main() {
>     histogram<int, int, int, int> f;
>     f.d<1,2>();
>     return 0;
> }
> ---END---
>
> So, msvc-14.0 gives the error (after tracing to the last function call in stack) at the position specified above. The error message which is coming from the AppVeyor logs (since I do not have msvc-14.0)
> ...
> C:\projects\boost-root\boost/mp11/utility.hpp(53): error C2971: 'boost::mp11::detail::mp_if_c_impl': template parameter 'C': 'C': a variable with non-static storage duration cannot be used as a non-type argument
> C:\projects\boost-root\boost/mp11/utility.hpp(38): note: see declaration of 'boost::mp11::detail::mp_if_c_impl'
> C:\projects\boost-root\boost/gil/histogram.hpp(247): note: see declaration of 'C'
> ...
>
> I am not sure if the issue is with mp11 or the msvc-14.0,

For the archive, I'm copying answer from Peter received on the Slack's
#boost-user

msvc 2015 bug
use
        histogram<boost::mp11::mp_at<type_list,
boost::mp11::mp_size_t<D>>...> f;
instead

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users