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

Ambiguous template instantiation for is_future_range and future_range_traits. #2032

Closed
ddemidov opened this issue Mar 16, 2016 · 1 comment · Fixed by #2043
Closed

Ambiguous template instantiation for is_future_range and future_range_traits. #2032

ddemidov opened this issue Mar 16, 2016 · 1 comment · Fixed by #2043

Comments

@ddemidov
Copy link
Contributor

The following example results in a compile error (on the master branch of hpx, fc3d1bf):

#include <vector>
#include <hpx/hpx.hpp>

typedef boost::iterator_range<
    std::vector< hpx::shared_future<void> >::iterator
    > future_range;

typedef hpx::traits::is_future_range<future_range>::type error1;

typedef hpx::traits::future_range_traits<future_range>::future_type error2;

int main() { }

The errors are:

/usr/include/boost/core/enable_if.hpp:41:10: error: ambiguous template instantiation for ‘struct hpx::traits::is_future_range<boost::iterator_range<__gnu_cxx::__normal_iterator<hpx::lcos::shared_future<void>*, std::vector<hpx::lcos::shared_future<void> > > >, void>’
   struct enable_if : public enable_if_c<Cond::value, T> {};
          ^
In file included from /usr/include/hpx/traits/acquire_shared_state.hpp:14:0,
                 from /usr/include/hpx/lcos/future.hpp:13,
                 from /usr/include/hpx/lcos/detail/async_implementations_fwd.hpp:11,
                 from /usr/include/hpx/runtime/components/stubs/stub_base.hpp:16,
                 from /usr/include/hpx/runtime/components/client_base.hpp:16,
                 from /usr/include/hpx/runtime/basename_registration.hpp:12,
                 from /usr/include/hpx/hpx_fwd.hpp:746,
                 from /usr/include/hpx/include/components.hpp:10,
                 from /usr/include/hpx/include/runtime.hpp:10,
                 from /usr/include/hpx/hpx.hpp:10,
                 from /home/demidov/tmp/hello/range.cpp:2:
/usr/include/hpx/traits/is_future_range.hpp:28:12: note: candidates are: template<class Range> struct hpx::traits::is_future_range<Range, typename boost::enable_if<hpx::traits::is_range<Range> >::type> [with Range = boost::iterator_range<__gnu_cxx::__normal_iterator<hpx::lcos::shared_future<void>*, std::vector<hpx::lcos::shared_future<void> > > >]
     struct is_future_range<Range,
            ^
/usr/include/hpx/traits/is_future_range.hpp:34:12: note:                 template<class Iterator> struct hpx::traits::is_future_range<boost::iterator_range<IteratorT> > [with Iterator = __gnu_cxx::__normal_iterator<hpx::lcos::shared_future<void>*, std::vector<hpx::lcos::shared_future<void> > >]
     struct is_future_range<boost::iterator_range<Iterator> >
            ^

and (after the second definition of is_future_range is commented out)

/home/demidov/tmp/hello/range.cpp:10:55: error: ambiguous template instantiation for ‘struct hpx::traits::future_range_traits<boost::iterator_range<__gnu_cxx::__normal_iterator<hpx::lcos::shared_future<void>*, std::vector<hpx::lcos::shared_future<void> > > > >’
 typedef hpx::traits::future_range_traits<future_range>::future_type error2;
                                                       ^
In file included from /usr/include/hpx/traits/acquire_shared_state.hpp:14:0,
                 from /usr/include/hpx/lcos/future.hpp:13,
                 from /usr/include/hpx/lcos/detail/async_implementations_fwd.hpp:11,
                 from /usr/include/hpx/runtime/components/stubs/stub_base.hpp:16,
                 from /usr/include/hpx/runtime/components/client_base.hpp:16,
                 from /usr/include/hpx/runtime/basename_registration.hpp:12,
                 from /usr/include/hpx/hpx_fwd.hpp:746,
                 from /usr/include/hpx/include/components.hpp:10,
                 from /usr/include/hpx/include/runtime.hpp:10,
                 from /usr/include/hpx/hpx.hpp:10,
                 from /home/demidov/tmp/hello/range.cpp:2:
/usr/include/hpx/traits/is_future_range.hpp:45:12: note: candidates are: template<class Range> struct hpx::traits::future_range_traits<Range, typename boost::enable_if<hpx::traits::is_future_range<Range> >::type> [with Range = boost::iterator_range<__gnu_cxx::__normal_iterator<hpx::lcos::shared_future<void>*, std::vector<hpx::lcos::shared_future<void> > > >]
     struct future_range_traits<
            ^
/usr/include/hpx/traits/is_future_range.hpp:53:12: note:                 template<class Iterator> struct hpx::traits::future_range_traits<boost::iterator_range<IteratorT>, typename boost::enable_if<hpx::traits::is_future<typename std::iterator_traits<_Iterator>::value_type> >::type> [with Iterator = __gnu_cxx::__normal_iterator<hpx::lcos::shared_future<void>*, std::vector<hpx::lcos::shared_future<void> > >]
     struct future_range_traits<
            ^

The second error may be fixed by commenting out the second definition of the future_range_traits. The candidates in the both errors do seem ambiguous to me, as is_range<boost::iterator_range> is true_type.

@ddemidov
Copy link
Contributor Author

If this is a correct way to fix this, I can make a PR.

@hkaiser hkaiser added this to the 0.9.12 milestone Mar 16, 2016
ddemidov added a commit to ddemidov/amgcl that referenced this issue Mar 17, 2016
Trying to resurrect the HPX backend example.
This compiles with fixes mentioned in STEllAR-GROUP/hpx#2032,
but does not seem to work correctly.
hkaiser added a commit that referenced this issue Mar 18, 2016
…raits

- adding test
- this fixes #2032
- this should be merged after #2041
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants