我正在使用 std::ptr_fun 如下: static inline std::string <rim(std::string &s) { s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))); return s; } 如本答案所示。 但是,这不能使用 C++17(使用 Microsoft Visual Studio 2017...
std::ptr_fun std::pointer_to_unary_function std::pointer_to_binary_function std::mem_fun_t, std::mem_fun1_t, std::const_mem_fun_t, std::const_mem_fun1_t std::not1 std::not2 std::bind1st, std::bind2nd std::mem_fun_ref_t, std::mem_fun1_ref_t, std::const_mem_fun_re...
=std::string::npos;}intmain(){std::string s="Hello, world!";std::copy_if(s.begin(),s.end(),std::ostreambuf_iterator<char>(std::cout),std::not1(std::ptr_fun(isvowel)));}
(s,std::ostreambuf_iterator<char>(std::cout),std::not1(std::ptr_fun(is_vowel)));#if 0// C++11 alternatives:std::not1(std::cref(is_vowel)));std::not1(std::function<bool(char)>(is_vowel)));[](charc){return!is_vowel(c);});// C++17 alternatives:std::not_fn(is_vowel)...
; std::ranges::copy_if(s, std::ostreambuf_iterator<char>(std::cout), std::not1(std::ptr_fun(is_vowel))); // C++11 替用方案: std::not1(std::cref(is_vowel))); std::not1(std::function<bool(char)>(is_vowel))); [](char c) { return !is_vowel(c); }); // C++17 ...
static inline std::string &rtrim(std::string &s) { s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end()); return s; } static inline std::string &trim(std::string &s) { return ltrim(rtrim(s)); }...
not1是用于创建返回传递的一元谓词的补的函数对象。创建的函数对象类型为std::unary_negate<Predicate>。 一元谓词类型必须定义成员类型argument_type,它可转换为谓词的形参类型。从std::ref、std::cref、std::negate、std::logical_not、std::mem_fn、std::function、std::hash或调用另一std::not1获得的一元函数...
std::nested_exception::nested_ptr std::nested_exception::rethrow_nested std::new_handler std::not1 std::not2 std::nothrow std::nothrow_t std::not_equal_to std::not_equal_to<void> std::not_fn std::nullopt std::nullopt_t std::nullptr_t std::numeric_limits std::numeric_limits::den...
=std::string::npos;}intmain(){std::strings="Hello, world!";std::copy_if(s.begin(), s.end(),std::ostreambuf_iterator<char>(std::cout),std::not1(std::ptr_fun(isvowel)));// C++11 替用方案:// std::not1(std::cref(isvowel)));// std::not1(std::function<bool(char)>(...
std::make_exception_ptr std::make_from_tuple std::make_optional std::make_pair std::make_shared std::make_signed std::make_tuple std::make_unique std::make_unsigned std::malloc std::max_align_t std::mem_fn std::mem_fun std::mem_fun1_ref_t std::mem_fun1_t std::mem_fun_ref...