c++ - Comparing iterator value_type in range constructor -


i'm writing range cosntructor custom container:

mycontainer(const inputiterator& first,              const inputiterator& last,              const allocator_type& alloc = allocator_type()) 

and check the inputiterator::value_type compatible container's value_type. tried tried:

static_assert(!(std::is_convertible<inputiterator::value_type, value_type>::value ||         std::is_same<inputiterator::value_type, value_type>::value), "error"); 

and went far as:

using inputiteratortype = typename std::decay<inputiterator>::type; using inputvaluetype = typename std::decay<inputiteratortype::value_type>::type; static_assert(!(std::is_convertible<inputvaluetype, value_type>::value ||         std::is_same<inputvaluetype, value_type>::value), "error"); 

but asserts, when use mycontainer::iterator input iterator.

how can check inputiterator compatible?

i'm guessing want std::is_constructible:

static_assert(std::is_constructible<     value_type,     decltype(*first)     >::value, "error"); 

or, alternatively, std::is_assignable, depending on whether you're constructing or assigning input iterators.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -