📄 tr1.qbk
字号:
[section:bind Function Object Binders.] #include <boost/tr1/functional.hpp>or #include <functional>`std::tr1::bind` is a generalization of the standard functions `std::bind1st`and `std::bind2nd`. It supports arbitrary function objects, functions, function pointers, and member function pointers, and is able to bind any argument to a specific value or route input arguments into arbitrary positions. `bind`does not place any requirements on the function object; in particular, it does not need the `result_type`, `first_argument_type` and `second_argument_type`standard typedefs.For more information refer to the [@../../libs/bind/bind.html Boost.Bind documentation]. namespace std { namespace tr1 { // [3.6] Function object binders template<class T> struct is_bind_expression; template<class T> struct is_placeholder; template<class F, class T1, ..., class Tn > unspecified bind(F f, T1 t1, ..., Tn tn ); template<class R, class F, class T1, ..., class Tn > unspecified bind(F f, T1 t1, ..., Tn tn ); namespace placeholders { // M is the implementation-defined number of placeholders extern unspecified _1; extern unspecified _2; . . . extern unspecified _M; } } // namespace tr1 } // namespace std[*Configuration:] [@../../libs/config/index.html Boost.Config] should (automatically) definethe macro BOOST_HAS_TR1_BIND if yourstandard library implements this part of TR1.[*Standard Conformity:]The traits classes `is_placeholder` and `is_bind_expression` are not supportedby the Boost implementation.The named return value syntax isn't supported if the object being bound is a function pointer, for example: std::tr1::bind(&my_proc, arg1, arg2 /* etc */); // works OK. std::tr1::bind<double>(&my_proc, arg1, arg2 /* etc */); // causes compiler error. std::tr1::bind<double>(my_function_object, arg1, arg2 /* etc */); // works OK.On the other hand, the Boost implementation does work with pointers to overloadedfunctions, and optionally with function pointers with non-standardcalling conventions.[endsect][section:function Polymorphic function wrappers.] #include <boost/tr1/functional.hpp>or #include <functional>The polymorphic function wrappers are a family of class templatesthat may be used as a generalized callback mechanism. A polymorphic function wrapper shares features with function pointers, inthat both define a call interface (for example a function taking two integerarguments and returning a floating-point value) through which somearbitrary code may be called. However a polymorphic function wrapper can callany callable object with a compatible call signature, this could be a function pointer, or it could be a function object produced by std::tr1::bind, or someother mechanism. For more information see the [@../../doc/html/function.htmlBoost.Function documentation]. namespace std { namespace tr1 { // [3.7] polymorphic function wrappers class bad_function_call; template<class Function> class function; template<class Function> void swap(function<Function>&, function<Function>&); template<class Function1, class Function2> void operator==(const function<Function1>&, const function<Function2>&); template<class Function1, class Function2> void operator!=(const function<Function1>&, const function<Function2>&); template <class Function> bool operator==(const function<Function>&, unspecified-null-pointer-type ); template <class Function> bool operator==(unspecified-null-pointer-type , const function<Function>&); template <class Function> bool operator!=(const function<Function>&, unspecified-null-pointer-type ); template <class Function> bool operator!=(unspecified-null-pointer-type , const function<Function>&); } // namespace tr1 } // namespace std[*Configuration:][@../../libs/config/index.html Boost.Config] should (automatically) definethe macro BOOST_HAS_TR1_FUNCTION if yourstandard library implements this part of TR1.[*Standard Conformity:]The Boost version of `std::tr1::function` lacks the member function`target_type()` and does not inherit from `std::unary_function`or `std::binary_function` when applicable. The member function target() can only access pointer-to-member targets when they have been wrapped in mem_fn.[endsect][section:type_traits Type Traits.] #include <boost/tr1/type_traits.hpp>or #include <type_traits>Type traits enable generic code to access the fundamental propertiesof a type, to determine the relationship between two types, or totransform one type into another related type. For more informationrefer to the [@../../libs/type_traits/index.html Boost.Type_traits documentation]. namespace std { namespace tr1 { template <class T, T v> struct integral_constant; typedef integral_constant<bool, true> true_type; typedef integral_constant<bool, false> false_type; // [4.5.1] primary type categories: template <class T> struct is_void; template <class T> struct is_integral; template <class T> struct is_floating_point; template <class T> struct is_array; template <class T> struct is_pointer; template <class T> struct is_reference; template <class T> struct is_member_object_pointer; template <class T> struct is_member_function_pointer; template <class T> struct is_enum; template <class T> struct is_union; template <class T> struct is_class; template <class T> struct is_function; // [4.5.2] composite type categories: template <class T> struct is_arithmetic; template <class T> struct is_fundamental; template <class T> struct is_object; template <class T> struct is_scalar; template <class T> struct is_compound; template <class T> struct is_member_pointer; // [4.5.3] type properties: template <class T> struct is_const; template <class T> struct is_volatile; template <class T> struct is_pod; template <class T> struct is_empty; template <class T> struct is_polymorphic; template <class T> struct is_abstract; template <class T> struct has_trivial_constructor; template <class T> struct has_trivial_copy; template <class T> struct has_trivial_assign; template <class T> struct has_trivial_destructor; template <class T> struct has_nothrow_constructor; template <class T> struct has_nothrow_copy; template <class T> struct has_nothrow_assign; template <class T> struct has_virtual_destructor; template <class T> struct is_signed; template <class T> struct is_unsigned; template <class T> struct alignment_of; template <class T> struct rank; template <class T, unsigned I = 0> struct extent; // [4.6] type relations: template <class T, class U> struct is_same; template <class Base, class Derived> struct is_base_of; template <class From, class To> struct is_convertible; // [4.7.1] const-volatile modifications: template <class T> struct remove_const; template <class T> struct remove_volatile; template <class T> struct remove_cv; template <class T> struct add_const; template <class T> struct add_volatile; template <class T> struct add_cv; // [4.7.2] reference modifications: template <class T> struct remove_reference; template <class T> struct add_reference; // [4.7.3] array modifications: template <class T> struct remove_extent; template <class T> struct remove_all_extents; // [4.7.4] pointer modifications: template <class T> struct remove_pointer; template <class T> struct add_pointer; // [4.8] other transformations: template <std::size_t Len, std::size_t Align> struct aligned_storage; } // namespace tr1 } // namespace std[*Configuration:][@../../libs/config/index.html Boost.Config] should (automatically) definethe macro BOOST_HAS_TR1_TYPE_TRAITS if yourstandard library implements this part of TR1.[*Standard Conformity:]No known problems.[endsect][section:random Random Number Generators and Distributions.] #include <boost/tr1/random.hpp> or #include <random>The random number library is divided into three parts: [@../../libs/random/random-generators.html generators], whichare nullary functors producing uniform random number distributions. [@../../libs/random/random-distributions.html Distributions], which are unary functors that adapt a generator to somespecific kind of distribution. And the class template [@../../libs/random/random-variate.html variate_generator]which combines a generator with a distribution, to create a new generator.For more information see the [@../../libs/random/index.html Boost.Random documentation]. namespace std { namespace tr1 { // [5.1.3] Class template variate_generator template<class UniformRandomNumberGenerator, class Distribution> class variate_generator; // [5.1.4.1] Class template linear_congruential template<class IntType, IntType a, IntType c, IntType m> class linear_congruential; // [5.1.4.2] Class template mersenne_twister template<class UIntType, int w, int n, int m, int r, UIntType a, int u, int s, UIntType b, int t, UIntType c, int l> class mersenne_twister; // [5.1.4.3] Class template substract_with_carry template<class IntType, IntType m, int s, int r> class subtract_with_carry; // [5.1.4.4] Class template substract_with_carry_01 template<class RealType, int w, int s, int r> class subtract_with_carry_01; // [5.1.4.5] Class template discard_block template<class UniformRandomNumberGenerator, int p, int r> class discard_block; // [5.1.4.6] Class template xor_combine template<class UniformRandomNumberGenerator1, int s1, class UniformRandomNumberGenerator2, int s2> class xor_combine; // [5.1.5] Predefined generators typedef linear_congruential< implementation-defined , 16807, 0, 2147483647> minstd_rand0; typedef linear_congruential< implementation-defined , 48271, 0, 2147483647> minstd_rand; typedef mersenne_twister< implementation-defined , 32, 624, 397, 31, 0x9908b0df, 11, 7, 0x9d2c5680, 15, 0xefc60000, 18> mt19937; typedef subtract_with_carry_01< float, 24, 10, 24> ranlux_base_01; typedef subtract_with_carry_01< double, 48, 10, 24> ranlux64_base_01; typedef discard_block< subtract_with_carry< implementation-defined , (1<<24), 10, 24>, 223, 24> ranlux3; typedef discard_block< subtract_with_carry< implementation-defined, (1<<24), 10, 24>, 389, 24> ranlux4; typedef discard_block< subtract_with_carry_01< float, 24, 10, 24>, 223, 24> ranlux3_01; typedef discard_block< subtract_with_carry_01< float, 24, 10, 24>, 389, 24> ranlux4_01; // [5.1.6] Class random_device class random_device; // [5.1.7.1] Class template uniform_int template<class IntType = int> class uniform_int; // [5.1.7.2] Class bernoulli_distribution class bernoulli_distribution; // [5.1.7.3] Class template geometric_distribution template<class IntType = int, class RealType = double> class geometric_distribution; // [5.1.7.4] Class template poisson_distribution template<class IntType = int, class RealType = double> class poisson_distribution; // [5.1.7.5] Class template binomial_distribution template<class IntType = int, class RealType = double> class binomial_distribution;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -