📄 algorithm.qbk
字号:
[[`f`][A unary function object][The search predicate]]][heading Expression Semantics] __none__(seq, f);[*Return type]: `bool`[*Semantics]: Returns true if and only if `f(e)` evaluates to `false` for every element `e` in `seq`. Result equivalent to `!any(seq, f)`.[heading Complexity]Linear. At most `__result_of_size__<Sequence>::value` comparisons.[heading Header] #include <boost/fusion/algorithm/query/none.hpp> #include <boost/fusion/include/none.hpp>[heading Example] struct odd { template<typename T> bool operator()(T t) const { return t % 2; } }; ... assert(__none__(__make_vector__(2,4), odd())); assert(!__none__(__make_vector__(1,2), odd()));[endsect][section find][heading Description]Finds the first element of a given type within a sequence.[heading Synopsis] template< typename T, typename Sequence > __unspecified__ find(Sequence const& seq); template< typename T, typename Sequence > __unspecified__ find(Sequence& seq);[table Parameters [[Parameter][Requirement][Description]] [[`seq`][A model of __forward_sequence__][The sequence to search]] [[`T`][Any type][The type to search for]]][heading Expression Semantics] __find__<T>(seq)[*Return type]: A model of the same iterator category as the iterators of `seq`.[*Semantics]: Returns an iterator to the first element of `seq` of type `T`, or `__end__(seq)` if there is no such element.Equivalent to `__find_if__<boost::is_same<_, T> >(seq)`[heading Complexity]Linear. At most `__result_of_size__<Sequence>::value` comparisons.[heading Header] #include <boost/fusion/algorithm/query/find.hpp> #include <boost/fusion/include/find.hpp>[heading Example] const __vector__<char,int> vec('a','0'); assert(*__find__<int>(vec) == '0'); assert(__find__<double>(vec) == __end__(vec));[endsect][section find_if]Finds the first element within a sequence with a type for which a given __mpl_lambda_expression__ evaluates to`boost::mpl::true_`.[heading Description][heading Synopsis] template< typename F, typename Sequence > __unspecified__ find_if(Sequence const& seq); template< typename F, typename Sequence > __unspecified__ find_if(Sequence& seq);[table Parameters [[Parameter][Requirement][Description]] [[`seq`][A model of __forward_sequence__][The sequence to search]] [[`F`][A unary __mpl_lambda_expression__][The search predicate]]][heading Expression Semantics] __find_if__<F>(seq)[*Return type]: An iterator of the same iterator category as the iterators of `seq`.[*Semantics]: Returns the first element of `seq` for which __mpl_lambda_expression__ `F` evaluates to `boost::mpl::true_`,or `__end__(seq)` if there is no such element.[heading Complexity]Linear. At most `__result_of_size__<Sequence>::value` comparisons./algorithm/query/find_if.hpp>[heading Example] const __vector__<double,int> vec(1.0,2); assert(*__find_if__<is_integral<mpl::_> >(vec) == 2); assert(__find_if__<is_class<mpl::_> >(vec) == __end__(vec));[endsect][section count][heading Description]Returns the number of elements of a given type within a sequence.[heading Synopsis] template< typename Sequence, typename T > typename __result_of_count__<Sequence, T>::type count( Sequence const& seq, T const& t);[table Parameters [[Parameter][Requirement][Description]] [[`seq`][A model of __forward_sequence__, `e == t` must be a valid expression, convertible to `bool`, for each element `e` in `seq`][The sequence to search]] [[`T`][Any type][The type to count]]][heading Expression Semantics] __count__(seq, t);[*Return type]: `int`[*Semantics]: Returns the number of elements of type `T` and equal to `t` in `seq`.[heading Complexity]Linear. At most `__result_of_size__<Sequence>::value` comparisons.[heading Header] #include <boost/fusion/algorithm/query/count.hpp> #include <boost/fusion/include/count.hpp>[heading Example] const __vector__<double,int,int> vec(1.0,2,3); assert(__count__(vec,2) == 1);[endsect][section count_if][heading Description]Returns the number of elements within a sequence with a type for which a given unary function object evaluates to`true`.[heading Synopsis] template< typename Sequence, typename F > typename __result_of_count_if__<Sequence, F>::type count_if( Sequence const& seq, F f);[table Parameters [[Parameter][Requirement][Description]] [[`seq`][A model of __forward_sequence__, `f(e)` is a valid expression, convertible to `bool`, for each element `e` in `seq`][The sequence to search]] [[`f`][A unary function object][The search predicate]]][heading Expression Semantics] __count_if__(seq, f)[*Return type]: `int`[*Semantics]: Returns the number of elements in `seq` where `f` evaluates to `true`.[heading Complexity]Linear. At most `__result_of_size__<Sequence>::value` comparisons.[heading Header] #include <boost/fusion/algorithm/query/count_if.hpp> #include <boost/fusion/include/count_if.hpp>[heading Example] const __vector__<int,int,int> vec(1,2,3); assert(__count_if__(vec,odd()) == 2);[endsect][endsect][section Metafunctions][section any][heading Description]A metafunction returning the result type of __any__.[heading Synopsis] template< typename Sequence, typename F > struct any { typedef bool type; };[table Parameters [[Parameter] [Requirement] [Description]] [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] [[`F`] [A model of unary __poly_func_obj__] [Operation's argument]]][heading Expression Semantics] __result_of_any__<Sequence, F>::type[*Return type]: `bool`.[*Semantics]: Returns the return type of __any__ given a sequence of type `Sequence` and a unary __poly_func_obj__ of type `F`. The return type is always `bool`.[heading Complexity]Constant.[heading Header] #include <boost/fusion/algorithm/query/any.hpp> #include <boost/fusion/include/any.hpp>[endsect][section all][heading Description]A metafunction returning the result type of __all__.[heading Synopsis] template< typename Sequence, typename F > struct all { typedef bool type; };[table Parameters [[Parameter] [Requirement] [Description]] [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] [[`F`] [A model of unary __poly_func_obj__] [Operation's argument]]][heading Expression Semantics] __result_of_all__<Sequence, F>::type[*Return type]: `bool`.[*Semantics]: Returns the return type of __all__ given a sequence of type `Sequence` and a unary __poly_func_obj__ of type `F`. The return type is always `bool`.[heading Complexity]Constant.[heading Header] #include <boost/fusion/algorithm/query/all.hpp> #include <boost/fusion/include/all.hpp>[endsect][section none][heading Description]A metafunction returning the result type of __none__.[heading Synopsis] template< typename Sequence, typename F > struct none { typedef bool type; };[table Parameters [[Parameter] [Requirement] [Description]] [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] [[`F`] [A model of unary __poly_func_obj__] [Operation's argument]]][heading Expression Semantics] __result_of_none__<Sequence, F>::type[*Return type]: `bool`.[*Semantics]: Returns the return type of __none__ given a sequence of type `Sequence` and a unary __poly_func_obj__ of type `F`. The return type is always `bool`.[heading Complexity]Constant.[heading Header] #include <boost/fusion/algorithm/query/none.hpp> #include <boost/fusion/include/none.hpp>[endsect][section find][heading Description]Returns the result type of `find`, given the sequence and search types.[heading Synopsis] template< typename Sequence, typename T > struct find { typedef __unspecified__ type; };[table Parameters [[Parameter] [Requirement] [Description]] [[`Sequence`] [Model of __forward_sequence__] [Operation's argument]] [[`T`] [Any type] [Operation's argument]]][heading Expression Semantics] __result_of_find__<Sequence, T>::type[*Return type]: A model of the same iterator category as the iterators of `Sequence`.[*Semantics]: Returns an iterator to the first element of type `T` in `Sequence`, or `__result_of_end__<Sequence>::type` if there is no such element.[heading Complexity]Linear, at most `__result_of_size__<Sequence>::value` comparisons.[heading Header] #include <boost/fusion/algorithm/query/find.hpp> #include <boost/fusion/include/find.hpp>[endsect][section find_if][heading Description]Returns the result type of `find_if` given the sequence and predicate types.[heading Synopsis] template< typename Sequence, typename Pred > struct find_if { typedef __unspecified__ type; };[table Parameters [[Parameter] [Requirement] [Description]] [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] [[`Pred`] [A model of __mpl_lambda_expression__] [Operation's arguments]]][heading Expression Semantics] __result_of_find_if__<Sequence, Pred>::type[*Return type]: A model of the same iterator category as the iterators of `Sequence`.[*Semantics]: Returns an iterator to the first element in `Sequence` for which `Pred` evaluates to true. Returns `__result_of_end__<Sequence>::type` if there is no such element.[heading Complexity]Linear. At most `__result_of_size__<Sequence>::value` comparisons.[heading Header] #include <boost/fusion/algorithm/query/find_if.hpp> #include <boost/fusion/include/find_if.hpp>[endsect][section count][heading Description]A metafunction that returns the result type of `count` given the sequence and search types.[heading Synopsis] template< typename Sequence, typename T > struct count { typedef int type; };[table Parameters [[Parameter] [Requirement] [heading Description]] [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] [[`T`] [Any type] [Operation's argument]]][heading Expression Semantics] __result_of_count__<T>::type[*Return type]: `int`.[*Semantics]: Returns the return type of __count__. The return type is always `int`.[heading Complexity]Constant.[heading Header] #include <boost/fusion/algorithm/query/count.hpp> #include <boost/fusion/include/count.hpp>[endsect][section count_if][heading Description]A metafunction that returns the result type of `count_if` given the sequence and predicate types.[heading Synopsis] template< typename Sequence, typename Pred > struct count_if { typedef int type; };[table Parameters [[Parameter] [Requirement] [Description]] [[`Sequence`] [A model of __forward_sequence__] [Operation's argument]] [[`Pred`] [A unary function object] [Operation's argument]]][heading Expression Semantics] __result_of_count_if__<Sequence, Pred>::type[*Return type]: `int`.[*Semantics]: Returns the return type of __count_if__. The return type is always `int`.[heading Complexity]Constant.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -