Boost logo

Boost Users :

From: Debabrata Mandal (mandaldebabrata123_at_[hidden])
Date: 2020-06-18 17:09:42


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
<https://developercommunity.visualstudio.com/content/problem/719235/erroneous-c2971-caused-by-using-variadic-by-ref-no.html>
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 list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net