c++ - How to use const qualifier with decltype? -
how use const
qualifier decltype
template-ed function ?
current gcc rejects following :
template <typename it> bool process(it first , last ) { return std::all_of( first, last, []( const decltype(*first)& ) // ^^^^^ without const works fine { return % 2 == 0; } ) ; }
is legal/possible use i
const
reference inside lambda ?
const decltype(*first)&
doesn't work because decltype(*first)
int&
, expect int
. can use std::remove_reference
work around (although doesn't make code clearer): const std::remove_reference<decltype(*first)>::type&
Comments
Post a Comment