]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/tr1/doc/tr1.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / tr1 / doc / tr1.qbk
CommitLineData
7c673cae
FG
1[library Boost.TR1
2 [quickbook 1.4]
3 [copyright 2005 John Maddock]
4 [purpose An implementation of the C++ Technical Report on Standard Library Extensions]
5 [license
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE_1_0.txt or copy at
8 [@http://www.boost.org/LICENSE_1_0.txt])]
9 [authors [Maddock, John]]
10 [category misc]
11 [last-revision $Date$]
12]
13
14[section:intro Introduction]
15
16[important This library is deprecated in favor of native C++11 standard library features, as a result
17it receives little or no maintenance.]
18
19The TR1 library provides an implementation of the C++ Technical Report on Standard Library Extensions.
20This library does not itself implement the TR1 components, rather it's a thin wrapper that will
21include your standard library's TR1 implementation (if it has one), otherwise it will include the Boost
22Library equivalents, and import them into namespace `std::tr1`.
23
24[endsect]
25
26[section:usage Usage]
27There are two things you need to decide before using the Boost.TR1 library:
28whether to use your standard library's native TR1 implementation (if it has one),
29and which include style to use.
30
31[section:native Whether to use Your Native TR1 Library]
32If your standard library implements the TR1, and you want to make
33use of it, rather than use the Boost equivalents, then you will need to
34take some explicit action to enable it: this may be a pre-processor
35define, a special compiler switch, or a different include path.
36You will need to consult your compilers documentation to find out
37which of these
38actions you need to take.
39
40Provided Boost is [link boost_tr1.config correctly configured],
41everything should
42now "just work", and code written to use Boost.TR1 will include
43your standard library's native headers rather than the Boost ones.
44
45[endsect]
46
47[section:include_style Header Include Style]
48
49There are two ways you can include the Boost.TR1 headers,
50for example if you are interested in shared_ptr then you can either use:
51
52 #include <boost/tr1/memory.hpp>
53
54or:
55
56 #include <memory>
57
58The first option is the preferred method for other Boost libraries
59to use. The second option is standard-conforming, but requires that you
60add `boost-install-path/boost/tr1/tr1` to your compiler's include search path.
61Note that you must not copy the headers in boost/tr1/tr1 into a directory
62called "include", doing so will cause them to cease working.
63
64[blurb [*Important Note #1]
65
66The include path order is very important if you want this library to work
67correctly. If you get compiler errors then suspect the include paths. The
68correct order is:
69
701) boost-root/boost/tr1/tr1\n
712) boost-root\n
723) Any other standard library replacements (STLport for example).\n
734) Your regular standard library.\n
74]
75
76[blurb [*Important Note #2: GNU C++ Users]
77
78Normally this library should "just work" with the GNU C++ compiler.
79
80However, if Boost is installed in `/usr/include` then you may get an error
81message of the form:
82
83``In file included from /usr/include/boost/tr1/tuple.hpp:5,
84 from boost-failure.cxx:1:
85/usr/include/boost/tr1/detail/config.hpp:60:26: error: no include path in which to search for utility``
86
87In this case try defining the macro `BOOST_TR1_DISABLE_INCLUDE_NEXT` when building,
88and if that doesn't work, define the macro `BOOST_TR1_GCC_INCLUDE_PATH` to the
89name of the directory containing gcc's include files: this is likely to be
90something like "g++-v4" but unfortunately varies from distribution
91to distribution.
92]
93
94[blurb [*Important Note #3: Borland C++ Users]
95
96Borland's compiler has a particularly broken form of `#include`, that
97will actually look for a file named `array.h` if you `#include <array>`.
98In order to make this library work with Borland's compiler you will need to
99set up the include paths as follows:
100
1011) boost-root/boost/tr1/tr1/bcc32\n
1022) boost-root/boost/tr1/tr1\n
1033) boost-root\n
1044) Any other standard library replacements (STLport for example).\n
1055) Your regular standard library.\n
106]
107
108[blurb [*Important Note #4: Sun C++ Users]
109
110Sun's compiler has a particularly interesting form of `#include`, that
111will actually look for a file named `array.SUNWCCh` if you `#include <array>`.
112What's more it won't include a standard header file that it thinks it's
113already seen.
114In order to make this library work with Sun's compiler you can either
115pass the undocumented compiler switch ['"-Qoption ccfe -nosunwcch"] to
116the compiler, or else you will need to
117set up the include paths as follows:
118
1191) boost-root/boost/tr1/tr1/sun\n
1202) boost-root/boost/tr1/tr1\n
1213) boost-root\n
1224) Any other standard library replacements (STLport for example).\n
1235) Your regular standard library.\n
124]
125
126[endsect]
127
128[section:writing_code Writing Code]
129
130Regardless of how the includes are setup, user code written to work
131with Boost.TR1 is exactly the same as code written to use a native
132tr1 implementation. That is, references to classes and functions
133need to explicitly use the `std::tr1` namespace or a `using namespace std::tr1`
134statement. For example,
135
136 std::tr1::tuple<int, std::string> t = std::tr1::make_tuple(10, "hello");
137
138or
139
140 using namespace std::tr1;
141 tuple<int, std::string> t = make_tuple(10, "hello");
142
143
144[endsect]
145
146
147[endsect]
148
149[section:config Configuration]
150
151Configuring Boost.TR1 is no different to configuring any other part of
152Boost; in the majority of cases you shouldn't actually need to do anything at all.
153However, because Boost.TR1 will inject Boost components into namespace std::tr1
154it is more than usually sensitive to an incorrect configuration.
155
156The intention is that
157[@../../libs/config/index.html Boost.Config]
158will automatically define the configuration
159macros used by this library, so that if your standard library is set up to
160support TR1 (note that few are at present) then this will be detected and Boost.TR1
161will use your standard library versions of these components rather than the
162Boost ones.
163
164If you would prefer to use the Boost versions of the TR1 conponents rather than
165your standard library, then either: include the Boost headers directly
166
167 #include <boost/regex.hpp>
168
169 boost::regex e("myregex"); //etc
170
171Or else don't enable TR1 in your standard library: since TR1 is not part of
172the current standard, there should be some option to disable it in your
173compiler or standard library.
174
175The configuration macros used by each TR1 component are documented in each
176library section (and all together in the
177[@../../libs/config/index.html Boost.Config]
178documentation), but defining BOOST_HAS_TR1 will turn on native TR1 support
179for everything (if your standard library has it), which can act as a
180convenient shortcut.
181
182[blurb [*Note for gcc users]\n\n
183Boost.TR1 does not currently enable gcc's native TR1 implementation
184as this is currently in an early stage of development. However, you may
185choose to do so by defining BOOST_HAS_GCC_TR1.]
186
187[endsect]
188
189[section:subject_list TR1 By Subject]
190
191[section:ref Reference Wrappers.]
192
193 #include <boost/tr1/functional.hpp>
194
195or
196
197 #include <functional>
198
199The Ref library is a small library that is useful for passing
200references to function templates (algorithms) that would usually
201take copies of their arguments. It defines the class template
202`reference_wrapper<T>`,
203and the two functions
204`ref` and `cref` that return
205instances of `reference_wrapper<T>`.
206[@../../doc/html/ref.html Refer to Boost.Bind for more information.]
207
208 namespace std {
209 namespace tr1 {
210
211 template <class T> class reference_wrapper;
212
213 template <class T> reference_wrapper<T> ref(T&);
214 template <class T> reference_wrapper<const T> cref(const T&);
215 template <class T> reference_wrapper<T> ref(reference_wrapper<T>);
216 template <class T> reference_wrapper<const T> cref(reference_wrapper<T>);
217
218 } // namespace tr1
219 } // namespace std
220
221[*Configuration:]
222[@../../libs/config/index.html Boost.Config] should (automatically) define
223the macro BOOST_HAS_TR1_REFERENCE_WRAPPER if your
224standard library implements this part of TR1.
225
226[*Standard Conformity:]
227The Boost version of this this component does not currently support
228function call invocation (2.1.2.4), or derivation from std::unary_function
229or std::binary_function (2.1.2 paragraphs 3 and 4).
230
231The Boost version is not implicitly convertible to T& as the TR requires.
232
233[endsect]
234
235[section:ptrs Smart Pointers.]
236
237 #include <boost/tr1/memory.hpp>
238
239or
240
241 #include <memory>
242
243The `shared_ptr` class template stores a pointer to a dynamically allocated
244object, typically with a C++ new-expression. The object pointed to is
245guaranteed to be deleted when the last `shared_ptr` pointing to it is
246destroyed or reset. For more information refer to the
247[@../../libs/smart_ptr/shared_ptr.htm shared_ptr]
248and [@../../libs/smart_ptr/weak_ptr.htm weak_ptr] documentation.
249
250 namespace std {
251 namespace tr1 {
252
253 class bad_weak_ptr;
254
255 // [2.2.3] Class template shared_ptr
256 template<class T> class shared_ptr;
257
258 // [2.2.3.6] shared_ptr comparisons
259 template<class T, class U> bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b);
260 template<class T, class U> bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b);
261 template<class T, class U> bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b);
262
263 // [2.2.3.8] shared_ptr specialized algorithms
264 template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b);
265
266 // [2.2.3.9] shared_ptr casts
267 template<class T, class U> shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r);
268 template<class T, class U> shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r);
269 template<class T, class U> shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r);
270
271 // [2.2.3.7] shared_ptr I/O
272 template<class E, class T, class Y>
273 basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, shared_ptr<Y> const& p);
274
275 // [2.2.3.10] shared_ptr get_deleter
276 template<class D, class T> D * get_deleter(shared_ptr<T> const& p);
277
278 // [2.2.4] Class template weak_ptr
279 template<class T> class weak_ptr;
280
281 // [2.2.4.6] weak_ptr comparison
282 template<class T, class U> bool operator<(weak_ptr<T> const& a, weak_ptr<U> const& b);
283
284 // [2.2.4.7] weak_ptr specialized algorithms
285 template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b);
286
287 // [2.2.5] Class enable_shared_from_this
288 template<class T> class enable_shared_from_this;
289
290 } // namespace tr1
291 } // namespace std
292
293[*Configuration:]
294[@../../libs/config/index.html Boost.Config] should (automatically) define
295the macro BOOST_HAS_TR1_SHARED_PTR if your
296standard library implements this part of TR1.
297
298[*Standard Conformity:] There are no known deviations from the standard when
299using the Boost version of this component.
300
301[endsect]
302
303[section:result_of Class template result_of.]
304
305 #include <boost/tr1/functional.hpp>
306
307or
308
309 #include <functional>
310
311The class template
312`result_of` helps determine the type of a
313call expression. Given an lvalue `f` of
314type `F` and lvalues `t1`,
315`t2, ..., tN` of
316types `T1, T2, ..., TN`, respectively, the type
317`result_of<F(T1, T2, ..., TN)>::type` defines the result type
318of the expression `f(t1, t2, ...,tN)`. The implementation permits
319the type `F` to be a function pointer,
320function reference, member function pointer, or class
321type. For more information
322[@../../libs/utility/utility.htm#result_of refer to the Boost.Utility documentation.]
323
324 namespace std {
325 namespace tr1 {
326
327 template <class T>
328 struct result_of
329 {
330 typedef unspecified type;
331 };
332
333 } // namespace tr1
334 } // namespace std
335
336[*Configuration:]
337[@../../libs/config/index.html Boost.Config] should (automatically) define
338the macro BOOST_HAS_TR1_RESULT_OF if your
339standard library implements this part of TR1.
340
341[*Standard Conformity:] No known problems.
342
343[endsect]
344
345[section:mem_fn Function template mem_fn.]
346
347 #include <boost/tr1/functional.hpp>
348
349or
350
351 #include <functional>
352
353`std::tr1::mem_fn` is a generalization of the standard functions `std::mem_fun`
354and `std::mem_fun_ref`. It supports member function pointers with more
355than one argument, and the returned function object can take a pointer, a
356reference, or a smart pointer to an object instance as its first argument. `mem_fn`
357also supports pointers to data members by treating them as functions taking no
358arguments and returning a (const) reference to the member.
359For more information refer to the [@../../libs/bind/mem_fn.html
360Boost.Mem_fn documentation].
361
362 namespace std {
363 namespace tr1 {
364
365 template <class R, class T> unspecified mem_fn(R T::* pm);
366
367 } // namespace tr1
368 } // namespace std
369
370[*Configuration:]
371[@../../libs/config/index.html Boost.Config] should (automatically) define
372the macro BOOST_HAS_TR1_MEM_FN if your
373standard library implements this part of TR1.
374
375[*Standard Conformity:]
376The Boost implementation does not produce functors that inherit from
377`std::unary_function` or `std::binary_function`, nor does it function
378correctly with pointers to volatile member functions (these should
379be extremely rare in practice however).
380
381[endsect]
382
383[section:bind Function Object Binders.]
384
385 #include <boost/tr1/functional.hpp>
386
387or
388
389 #include <functional>
390
391`std::tr1::bind` is a generalization of the standard functions `std::bind1st`
392and `std::bind2nd`. It supports arbitrary function objects, functions,
393function pointers, and member function pointers, and is able to bind any
394argument to a specific value or route input arguments into arbitrary positions. `bind`
395does not place any requirements on the function object; in particular, it does
396not need the `result_type`, `first_argument_type` and `second_argument_type`
397standard typedefs.
398For more information refer to the [@../../libs/bind/bind.html
399Boost.Bind documentation].
400
401 namespace std {
402 namespace tr1 {
403
404 // [3.6] Function object binders
405 template<class T> struct is_bind_expression;
406 template<class T> struct is_placeholder;
407 template<class F, class T1, ..., class Tn > unspecified bind(F f, T1 t1, ..., Tn tn );
408 template<class R, class F, class T1, ..., class Tn > unspecified bind(F f, T1 t1, ..., Tn tn );
409
410 namespace placeholders {
411 // M is the implementation-defined number of placeholders
412 extern unspecified _1;
413 extern unspecified _2;
414 .
415 .
416 .
417 extern unspecified _M;
418 }
419
420 } // namespace tr1
421 } // namespace std
422
423[*Configuration:]
424[@../../libs/config/index.html Boost.Config] should (automatically) define
425the macro BOOST_HAS_TR1_BIND if your
426standard library implements this part of TR1.
427
428[*Standard Conformity:]
429The traits classes `is_placeholder` and `is_bind_expression` are not supported
430by the Boost implementation.
431
432The named return value syntax isn't supported if the object being bound is a
433function pointer, for example:
434
435 std::tr1::bind(&my_proc, arg1, arg2 /* etc */); // works OK.
436 std::tr1::bind<double>(&my_proc, arg1, arg2 /* etc */); // causes compiler error.
437 std::tr1::bind<double>(my_function_object, arg1, arg2 /* etc */); // works OK.
438
439On the other hand, the Boost implementation does work with pointers to overloaded
440functions, and optionally with function pointers with non-standard
441calling conventions.
442
443[endsect]
444
445[section:function Polymorphic function wrappers.]
446
447 #include <boost/tr1/functional.hpp>
448
449or
450
451 #include <functional>
452
453The polymorphic function wrappers are a family of class templates
454that may be used as a generalized callback mechanism.
455A polymorphic function wrapper shares features with function pointers, in
456that both define a call interface (for example a function taking two integer
457arguments and returning a floating-point value) through which some
458arbitrary code may be called. However a polymorphic function wrapper can call
459any callable object with a compatible call signature, this could be a function
460pointer, or it could be a function object produced by std::tr1::bind, or some
461other mechanism. For more information see the [@../../doc/html/function.html
462Boost.Function documentation].
463
464
465 namespace std {
466 namespace tr1 {
467
468 // [3.7] polymorphic function wrappers
469 class bad_function_call;
470
471 template<class Function>
472 class function;
473
474 template<class Function>
475 void swap(function<Function>&, function<Function>&);
476
477 template<class Function1, class Function2>
478 void operator==(const function<Function1>&, const function<Function2>&);
479 template<class Function1, class Function2>
480 void operator!=(const function<Function1>&, const function<Function2>&);
481 template <class Function>
482 bool operator==(const function<Function>&, unspecified-null-pointer-type );
483 template <class Function>
484 bool operator==(unspecified-null-pointer-type , const function<Function>&);
485 template <class Function>
486 bool operator!=(const function<Function>&, unspecified-null-pointer-type );
487 template <class Function>
488 bool operator!=(unspecified-null-pointer-type , const function<Function>&);
489
490 } // namespace tr1
491 } // namespace std
492
493[*Configuration:]
494[@../../libs/config/index.html Boost.Config] should (automatically) define
495the macro BOOST_HAS_TR1_FUNCTION if your
496standard library implements this part of TR1.
497
498[*Standard Conformity:]
499The Boost version of `std::tr1::function` lacks the member function
500`target_type()` and does not inherit from `std::unary_function`
501or `std::binary_function` when applicable. The member function
502target() can only access pointer-to-member targets when they
503have been wrapped in mem_fn.
504
505[endsect]
506
507[section:type_traits Type Traits.]
508
509 #include <boost/tr1/type_traits.hpp>
510
511or
512
513 #include <type_traits>
514
515Type traits enable generic code to access the fundamental properties
516of a type, to determine the relationship between two types, or to
517transform one type into another related type. For more information
518refer to the [@../../libs/type_traits/index.html Boost.Type_traits documentation].
519
520 namespace std {
521 namespace tr1 {
522
523 template <class T, T v> struct integral_constant;
524
525 typedef integral_constant<bool, true> true_type;
526 typedef integral_constant<bool, false> false_type;
527
528 // [4.5.1] primary type categories:
529 template <class T> struct is_void;
530 template <class T> struct is_integral;
531 template <class T> struct is_floating_point;
532 template <class T> struct is_array;
533 template <class T> struct is_pointer;
534 template <class T> struct is_reference;
535 template <class T> struct is_member_object_pointer;
536 template <class T> struct is_member_function_pointer;
537 template <class T> struct is_enum;
538 template <class T> struct is_union;
539 template <class T> struct is_class;
540 template <class T> struct is_function;
541
542 // [4.5.2] composite type categories:
543 template <class T> struct is_arithmetic;
544 template <class T> struct is_fundamental;
545 template <class T> struct is_object;
546 template <class T> struct is_scalar;
547 template <class T> struct is_compound;
548 template <class T> struct is_member_pointer;
549
550 // [4.5.3] type properties:
551 template <class T> struct is_const;
552 template <class T> struct is_volatile;
553 template <class T> struct is_pod;
554 template <class T> struct is_empty;
555 template <class T> struct is_polymorphic;
556 template <class T> struct is_abstract;
557 template <class T> struct has_trivial_constructor;
558 template <class T> struct has_trivial_copy;
559 template <class T> struct has_trivial_assign;
560 template <class T> struct has_trivial_destructor;
561 template <class T> struct has_nothrow_constructor;
562 template <class T> struct has_nothrow_copy;
563 template <class T> struct has_nothrow_assign;
564 template <class T> struct has_virtual_destructor;
565 template <class T> struct is_signed;
566 template <class T> struct is_unsigned;
567 template <class T> struct alignment_of;
568 template <class T> struct rank;
569 template <class T, unsigned I = 0> struct extent;
570
571 // [4.6] type relations:
572 template <class T, class U> struct is_same;
573 template <class Base, class Derived> struct is_base_of;
574 template <class From, class To> struct is_convertible;
575
576 // [4.7.1] const-volatile modifications:
577 template <class T> struct remove_const;
578 template <class T> struct remove_volatile;
579 template <class T> struct remove_cv;
580 template <class T> struct add_const;
581 template <class T> struct add_volatile;
582 template <class T> struct add_cv;
583
584 // [4.7.2] reference modifications:
585 template <class T> struct remove_reference;
586 template <class T> struct add_reference;
587
588 // [4.7.3] array modifications:
589 template <class T> struct remove_extent;
590 template <class T> struct remove_all_extents;
591
592 // [4.7.4] pointer modifications:
593 template <class T> struct remove_pointer;
594 template <class T> struct add_pointer;
595
596 // [4.8] other transformations:
597 template <std::size_t Len, std::size_t Align> struct aligned_storage;
598
599 } // namespace tr1
600 } // namespace std
601
602[*Configuration:]
603[@../../libs/config/index.html Boost.Config] should (automatically) define
604the macro BOOST_HAS_TR1_TYPE_TRAITS if your
605standard library implements this part of TR1.
606
607[*Standard Conformity:]
608No known problems.
609
610[endsect]
611
612[section:random Random Number Generators and Distributions.]
613
614 #include <boost/tr1/random.hpp>
615
616or
617
618 #include <random>
619
620The random number library is divided into three parts:
621[@../../libs/random/random-generators.html generators], which
622are nullary functors producing uniform random number distributions.
623[@../../libs/random/random-distributions.html Distributions], which are unary
624functors that adapt a generator to some
625specific kind of distribution. And the class template
626[@../../libs/random/random-variate.html variate_generator]
627which combines a generator with a distribution, to create a new generator.
628For more information see the [@../../libs/random/index.html Boost.Random documentation].
629
630
631 namespace std {
632 namespace tr1 {
633
634 // [5.1.3] Class template variate_generator
635 template<class UniformRandomNumberGenerator, class Distribution>
636 class variate_generator;
637
638 // [5.1.4.1] Class template linear_congruential
639 template<class IntType, IntType a, IntType c, IntType m>
640 class linear_congruential;
641
642 // [5.1.4.2] Class template mersenne_twister
643 template<class UIntType, int w, int n, int m, int r,
644 UIntType a, int u, int s, UIntType b, int t, UIntType c, int l>
645 class mersenne_twister;
646
647 // [5.1.4.3] Class template substract_with_carry
648 template<class IntType, IntType m, int s, int r>
649 class subtract_with_carry;
650
651 // [5.1.4.4] Class template substract_with_carry_01
652 template<class RealType, int w, int s, int r>
653 class subtract_with_carry_01;
654
655 // [5.1.4.5] Class template discard_block
656 template<class UniformRandomNumberGenerator, int p, int r>
657 class discard_block;
658
659 // [5.1.4.6] Class template xor_combine
660 template<class UniformRandomNumberGenerator1, int s1,
661 class UniformRandomNumberGenerator2, int s2>
662 class xor_combine;
663
664 // [5.1.5] Predefined generators
665 typedef linear_congruential<
666 implementation-defined ,
667 16807,
668 0,
669 2147483647> minstd_rand0;
670
671 typedef linear_congruential<
672 implementation-defined ,
673 48271,
674 0,
675 2147483647> minstd_rand;
676
677 typedef mersenne_twister<
678 implementation-defined ,
679 32, 624, 397, 31,
680 0x9908b0df, 11, 7,
681 0x9d2c5680, 15,
682 0xefc60000, 18> mt19937;
683
684 typedef subtract_with_carry_01<
685 float,
686 24,
687 10,
688 24> ranlux_base_01;
689
690 typedef subtract_with_carry_01<
691 double,
692 48,
693 10,
694 24> ranlux64_base_01;
695
696 typedef discard_block<
697 subtract_with_carry<
698 implementation-defined ,
699 (1<<24),
700 10,
701 24>,
702 223,
703 24> ranlux3;
704
705 typedef discard_block<
706 subtract_with_carry<
707 implementation-defined,
708 (1<<24),
709 10,
710 24>,
711 389,
712 24> ranlux4;
713
714 typedef discard_block<
715 subtract_with_carry_01<
716 float,
717 24,
718 10,
719 24>,
720 223,
721 24> ranlux3_01;
722
723 typedef discard_block<
724 subtract_with_carry_01<
725 float,
726 24,
727 10,
728 24>,
729 389,
730 24> ranlux4_01;
731
732 // [5.1.6] Class random_device
733 class random_device;
734
735 // [5.1.7.1] Class template uniform_int
736 template<class IntType = int>
737 class uniform_int;
738
739 // [5.1.7.2] Class bernoulli_distribution
740 class bernoulli_distribution;
741
742 // [5.1.7.3] Class template geometric_distribution
743 template<class IntType = int, class RealType = double>
744 class geometric_distribution;
745
746 // [5.1.7.4] Class template poisson_distribution
747 template<class IntType = int, class RealType = double>
748 class poisson_distribution;
749
750 // [5.1.7.5] Class template binomial_distribution
751 template<class IntType = int, class RealType = double>
752 class binomial_distribution;
753
754 // [5.1.7.6] Class template uniform_real
755 template<class RealType = double>
756 class uniform_real;
757
758 // [5.1.7.7] Class template exponential_distribution
759 template<class RealType = double>
760 class exponential_distribution;
761
762 // [5.1.7.8] Class template normal_distribution
763 template<class RealType = double>
764 class normal_distribution;
765
766 // [5.1.7.9] Class template gamma_distribution
767 template<class RealType = double>
768 class gamma_distribution;
769
770 } // namespace tr1
771 } // namespace std
772
773[*Configuration:]
774[@../../libs/config/index.html Boost.Config] should (automatically) define
775the macro BOOST_HAS_TR1_RANDOM if your
776standard library implements this part of TR1.
777
778[*Standard Conformity:]
779The Boost implementation has the following limitations:
780
781*The linear_congruential generator is fully supported for
782signed integer types only (unsigned types probably only work when
783the modulus is zero).
784*The subtract_with_carry template does not support a modulus of zero.
785*Not all of the standard generator types have Boost documentation yet, they are
786none the less supported however.
787*Class template variate_generator does not have a template unary function call operator(),
788only the non-template nullary version.
789
790Note also that most of the Random number generators have been re-implemented
791as thin wrappers around the Boost versions in order to
792provide a standard conforming interface (the Boost versions all take an additional,
793redundant, template parameter, and are initialized by iterators rather than functors).
794
795[endsect]
796
797[section:tuple Tuples.]
798
799 #include <boost/tr1/tuple.hpp>
800
801or
802
803 #include <tuple>
804
805A tuple is a fixed size collection of elements.
806Pairs, triples, quadruples etc. are tuples.
807In a programming language, a tuple is a data object containing other objects as elements.
808These element objects may be of different types.
809Tuples are convenient in many circumstances.
810For instance, tuples make it easy to define functions that return more than one value.
811Some programming languages, such as ML, Python and Haskell, have built-in tuple constructs.
812Unfortunately C++ does not.
813To compensate for this "deficiency", the TR1 Tuple Library implements a tuple construct using templates.
814For more information see the [@../../libs/tuple/index.html Boost Tuple Library Documentation].
815
816 namespace std {
817 namespace tr1 {
818
819 // [6.1.3] Class template tuple
820 template <class T1 = unspecified ,
821 class T2 = unspecified ,
822 ...,
823 class TM = unspecified > class tuple;
824
825 // [6.1.3.2] Tuple creation functions
826 const unspecified ignore;
827
828 template<class T1, class T2, ..., class TN>
829 tuple<V1, V2, ..., VN> make_tuple(const T1&, const T2& , ..., const TN&);
830
831 // [6.1] Tuple types Containers
832 template<class T1, class T2, ..., class TN>
833 tuple<T1&, T2&, ..., TN&> tie(T1&, T2& , ..., TN&);
834
835 // [6.1.3.3] Tuple helper classes
836 template <class T> class tuple_size;
837 template <int I, class T> class tuple_element;
838
839 // [6.1.3.4] Element access
840 template <int I, class T1, class T2, ..., class TN>
841 RI get(tuple<T1, T2, ..., TN>&);
842 template <int I, class T1, class T2, ..., class TN>
843 PI get(const tuple<T1, T2, ..., TN>&);
844
845 // [6.1.3.5] relational operators
846 template<class T1, class T2, ..., class TM, class U1, class U2, ..., class UM>
847 bool operator==(const tuple<T1, T2, ..., TM>&, const tuple<U1, U2, ..., UM>&);
848 template<class T1, class T2, ..., class TM, class U1, class U2, ..., class UM>
849 bool operator<(const tuple<T1, T2, ..., TM>&, const tuple<U1, U2, ..., UM>&);
850 template<class T1, class T2, ..., class TM, class U1, class U2, ..., class UM>
851 bool operator!=(const tuple<T1, T2, ..., TM>&, const tuple<U1, U2, ..., UM>&);
852 template<class T1, class T2, ..., class TM, class U1, class U2, ..., class UM>
853 bool operator>(const tuple<T1, T2, ..., TM>&, const tuple<U1, U2, ..., UM>&);
854 template<class T1, class T2, ..., class TM, class U1, class U2, ..., class UM>
855 bool operator<=(const tuple<T1, T2, ..., TM>&, const tuple<U1, U2, ..., UM>&);
856 template<class T1, class T2, ..., class TM, class U1, class U2, ..., class UM>
857 bool operator>=(const tuple<T1, T2, ..., TM>&, const tuple<U1, U2, ..., UM>&);
858
859 } // namespace tr1
860 } // namespace std
861
862[*Configuration:]
863[@../../libs/config/index.html Boost.Config] should (automatically) define
864the macro BOOST_HAS_TR1_TUPLE if your
865standard library implements this part of TR1.
866
867[*Standard Conformity:]
868No known issues for conforming compilers.
869
870[endsect]
871
872[section:utility Tuple Interface to std::pair.]
873
874 #include <boost/tr1/utility.hpp>
875
876or
877
878 #include <utility>
879
880The existing class template std::pair, can also be accessed using the
881[link boost_tr1.subject_list.tuple tuple interface].
882
883 namespace std {
884 namespace tr1 {
885
886 template <class T> class tuple_size; // forward declaration
887 template <int I, class T> class tuple_element; // forward declaration
888 template <class T1, class T2> struct tuple_size<std::pair<T1, T2> >;
889 template <class T1, class T2> struct tuple_element<0, std::pair<T2, T2> >;
890 template <class T1, class T2> struct tuple_element<1, std::pair<T2, T2> >;
891 // see below for definition of "P".
892 template<int I, class T1, class T2> P& get(std::pair<T1, T2>&);
893 template<int I, class T1, class T2> const P& get(const std::pair<T1, T2>&);
894
895 } // namespace tr1
896 } // namespace std
897
898[*Configuration:]
899[@../../libs/config/index.html Boost.Config] should (automatically) define
900the macro BOOST_HAS_TR1_UTILITY if your
901standard library implements this part of TR1.
902
903[*Standard Conformity:]
904No known problems.
905
906[endsect]
907
908[section:array Fixed Size Array.]
909
910 #include <boost/tr1/array.hpp>
911
912or
913
914 #include <array>
915
916Class template array is a fixed size array that is safer than and no
917less efficient than a C style array. Class array fulfils almost all of the
918requirements of a reversible-container (see Section 23.1,
919[lib.container.requirements] of the C++ Standard). For more information refer
920to the [@../../libs/array/index.html Boost.Array documentation].
921
922 namespace std {
923 namespace tr1 {
924
925 // [6.2.2] Class template array
926 template <class T, size_t N > struct array;
927
928 // Array comparisons
929 template <class T, size_t N> bool operator== (const array<T,N>& x, const array<T,N>& y);
930 template <class T, size_t N> bool operator< (const array<T,N>& x, const array<T,N>& y);
931 template <class T, size_t N> bool operator!= (const array<T,N>& x, const array<T,N>& y);
932 template <class T, size_t N> bool operator> (const array<T,N>& x, const array<T,N>& y);
933 template <class T, size_t N> bool operator>= (const array<T,N>& x, const array<T,N>& y);
934 template <class T, size_t N> bool operator<= (const array<T,N>& x, const array<T,N>& y);
935
936 // [6.2.2.2] Specialized algorithms
937 template <class T, size_t N > void swap(array<T,N>& x, array<T,N>& y);
938
939 // [6.2.2.5] Tuple interface to class template array
940 template <class T> class tuple_size; // forward declaration
941 template <int I, class T> class tuple_element; // forward declaration
942 template <class T, size_t N> struct tuple_size<array<T, N> >;
943 template <int I, class T, size_t N> struct tuple_element<I, array<T, N> >;
944 template <int I, class T, size_t N> T& get( array<T, N>&);
945 template <int I, class T, size_t N> const T& get(const array<T, N>&);
946
947 } // namespace tr1
948 } // namespace std
949
950[*Configuration:]
951[@../../libs/config/index.html Boost.Config] should (automatically) define
952the macro BOOST_HAS_TR1_ARRAY if your
953standard library implements this part of TR1.
954
955[*Standard Conformity:]
956No known issues as of Boost-1.34 onwards.
957
958[endsect]
959
960[section:hash Hash Function Objects.]
961
962 #include <boost/tr1/functional.hpp>
963
964or
965
966 #include <functional>
967
968Class template std::hash is a unary-functor that converts some type T
969into a hash-value,
970specializations of std::hash are provided for integer, character, floating point,
971and pointer types, plus the two string types std::string and std::wstring.
972See the [@../../libs/functional/hash/index.html Boost.Hash]
973documentation for more information.
974
975 namespace std {
976 namespace tr1 {
977
978 template <class T>
979 struct hash : public unary_function<T, size_t>
980 {
981 size_t operator()(T val)const;
982 };
983
984 // Hash function specializations
985 template <> struct hash<bool>;
986 template <> struct hash<char>;
987 template <> struct hash<signed char>;
988 template <> struct hash<unsigned char>;
989 template <> struct hash<wchar_t>;
990 template <> struct hash<short>;
991 template <> struct hash<int>;
992 template <> struct hash<long>;
993 template <> struct hash<unsigned short>;
994 template <> struct hash<unsigned int>;
995 template <> struct hash<unsigned long>;
996 template <> struct hash<float>;
997 template <> struct hash<double>;
998 template <> struct hash<long double>;
999 template<class T> struct hash<T*>;
1000 template <> struct hash<std::string>;
1001 template <> struct hash<std::wstring>;
1002
1003 } // namespace tr1
1004 } // namespace std
1005
1006[*Configuration:]
1007[@../../libs/config/index.html Boost.Config] should (automatically) define
1008the macro BOOST_HAS_TR1_HASH if your
1009standard library implements this part of TR1.
1010
1011[*Standard Conformity:]
1012Boost.Hash adds specialisations of std::hash for a wider range of types
1013than those required by TR1: Boost.Hash acts as a testbed for issue 6.18
1014in the [@http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf
1015Library Extension Technical Report Issues List].
1016
1017[note There are portability issues with this template - in particular the `hash` template
1018might not actually be defined inside namespace std::tr1, making user-defined specializations
1019of the template non-portable. For example Visual C++ 2010 defines `hash` in namespace `std`
1020and then imports this into `std::tr1` with a using declaration.]
1021
1022[endsect]
1023
1024[section:regex Regular Expressions.]
1025
1026 #include <boost/tr1/regex.hpp>
1027
1028or
1029
1030 #include <regex>
1031
1032This library provides comprehensive support for regular expressions,
1033including either iterator or string based matching, searching, search-and-replace,
1034iteration, and tokenization. Both POSIX and ECMAScript (JavaScript) regular
1035expressions are supported. For more information see the [@../../libs/regex/index.html
1036Boost.Regex documentation].
1037
1038 namespace std {
1039 namespace tr1 {
1040
1041 // [7.5] Regex constants
1042 namespace regex_constants {
1043
1044 typedef bitmask_type syntax_option_type;
1045 typedef bitmask_type match_flag_type;
1046 typedef implementation-defined error_type;
1047
1048 } // namespace regex_constants
1049
1050 // [7.6] Class regex_error
1051 class regex_error;
1052
1053 // [7.7] Class template regex_traits
1054 template <class charT> struct regex_traits;
1055
1056 // [7.8] Class template basic_regex
1057 template <class charT, class traits = regex_traits<charT> >
1058 class basic_regex;
1059
1060 typedef basic_regex<char> regex;
1061 typedef basic_regex<wchar_t> wregex;
1062
1063 // [7.8.6] basic_regex swap
1064 template <class charT, class traits>
1065 void swap(basic_regex<charT, traits>& e1,
1066 basic_regex<charT, traits>& e2);
1067
1068 // [7.9] Class template sub_match
1069 template <class BidirectionalIterator>
1070 class sub_match;
1071
1072 typedef sub_match<const char*> csub_match;
1073 typedef sub_match<const wchar_t*> wcsub_match;
1074 typedef sub_match<string::const_iterator> ssub_match;
1075 typedef sub_match<wstring::const_iterator> wssub_match;
1076
1077 // [7.9.2] sub_match non-member operators
1078
1079 /* Comparison operators omitted for clarity.... */
1080
1081 template <class charT, class ST, class BiIter>
1082 basic_ostream<charT, ST>&
1083 operator<<(basic_ostream<charT, ST>& os,
1084 const sub_match<BiIter>& m);
1085
1086 // [7.10] Class template match_results
1087 template <class BidirectionalIterator,
1088 class Allocator = allocator<sub_match<BidirectionalIterator> > >
1089 class match_results;
1090
1091 typedef match_results<const char*> cmatch;
1092 typedef match_results<const wchar_t*> wcmatch;
1093 typedef match_results<string::const_iterator> smatch;
1094 typedef match_results<wstring::const_iterator> wsmatch;
1095
1096 // match_results comparisons
1097 template <class BidirectionalIterator, class Allocator>
1098 bool operator== (const match_results<BidirectionalIterator, Allocator>& m1,
1099 const match_results<BidirectionalIterator, Allocator>& m2);
1100 template <class BidirectionalIterator, class Allocator>
1101 bool operator!= (const match_results<BidirectionalIterator, Allocator>& m1,
1102 const match_results<BidirectionalIterator, Allocator>& m2);
1103
1104 // [7.10.6] match_results swap
1105 template <class BidirectionalIterator, class Allocator>
1106 void swap(match_results<BidirectionalIterator, Allocator>& m1,
1107 match_results<BidirectionalIterator, Allocator>& m2);
1108
1109 // [7.11.2] Function template regex_match
1110 template <class BidirectionalIterator, class Allocator, class charT, class traits>
1111 bool regex_match(BidirectionalIterator first,
1112 BidirectionalIterator last,
1113 match_results<BidirectionalIterator, Allocator>& m,
1114 const basic_regex<charT, traits>& e,
1115 regex_constants::match_flag_type flags = regex_constants::match_default);
1116
1117 template <class BidirectionalIterator, class charT, class traits>
1118 bool regex_match(BidirectionalIterator first,
1119 BidirectionalIterator last,
1120 const basic_regex<charT, traits>& e,
1121 regex_constants::match_flag_type flags = regex_constants::match_default);
1122
1123 template <class charT, class Allocator, class traits>
1124 bool regex_match(const charT* str,
1125 match_results<const charT*, Allocator>& m,
1126 const basic_regex<charT, traits>& e,
1127 regex_constants::match_flag_type flags = regex_constants::match_default);
1128
1129 template <class ST, class SA, class Allocator, class charT, class traits>
1130 bool regex_match(const basic_string<charT, ST, SA>& s,
1131 match_results<typename basic_string<charT, ST, SA>::const_iterator,Allocator>& m,
1132 const basic_regex<charT, traits>& e,
1133 regex_constants::match_flag_type flags = regex_constants::match_default);
1134
1135 template <class charT, class traits>
1136 bool regex_match(const charT* str,
1137 const basic_regex<charT, traits>& e,
1138 regex_constants::match_flag_type flags = regex_constants::match_default);
1139
1140 template <class ST, class SA, class charT, class traits>
1141 bool regex_match(const basic_string<charT, ST, SA>& s,
1142 const basic_regex<charT, traits>& e,
1143 regex_constants::match_flag_type flags = regex_constants::match_default);
1144
1145 // [7.11.3] Function template regex_search
1146 template <class BidirectionalIterator, class Allocator, class charT, class traits>
1147 bool regex_search(BidirectionalIterator first,
1148 BidirectionalIterator last,
1149 match_results<BidirectionalIterator, Allocator>& m,
1150 const basic_regex<charT, traits>& e,
1151 regex_constants::match_flag_type flags = regex_constants::match_default);
1152
1153 template <class BidirectionalIterator, class charT, class traits>
1154 bool regex_search(BidirectionalIterator first,
1155 BidirectionalIterator last,
1156 const basic_regex<charT, traits>& e,
1157 regex_constants::match_flag_type flags = regex_constants::match_default);
1158
1159 template <class charT, class Allocator, class traits>
1160 bool regex_search(const charT* str,
1161 match_results<const charT*, Allocator>& m,
1162 const basic_regex<charT, traits>& e,
1163 regex_constants::match_flag_type flags = regex_constants::match_default);
1164
1165 template <class charT, class traits>
1166 bool regex_search(const charT* str,
1167 const basic_regex<charT, traits>& e,
1168 regex_constants::match_flag_type flags = regex_constants::match_default);
1169
1170 template <class ST, class SA, class charT, class traits>
1171 bool regex_search(const basic_string<charT, ST, SA>& s,
1172 const basic_regex<charT, traits>& e,
1173 regex_constants::match_flag_type flags = regex_constants::match_default);
1174
1175 template <class ST, class SA, class Allocator, class charT, class traits>
1176 bool regex_search(const basic_string<charT, ST, SA>& s,
1177 match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
1178 const basic_regex<charT, traits>& e,
1179 regex_constants::match_flag_type flags = regex_constants::match_default);
1180
1181 // [7.11.4] Function template regex_replace
1182 template <class OutputIterator, class BidirectionalIterator, class traits, class charT>
1183 OutputIterator regex_replace(OutputIterator out,
1184 BidirectionalIterator first,
1185 BidirectionalIterator last,
1186 const basic_regex<charT, traits>& e,
1187 const basic_string<charT>& fmt,
1188 regex_constants::match_flag_type flags = regex_constants::match_default);
1189
1190 template <class traits, class charT>
1191 basic_string<charT> regex_replace(const basic_string<charT>& s,
1192 const basic_regex<charT, traits>& e,
1193 const basic_string<charT>& fmt,
1194 regex_constants::match_flag_type flags = regex_constants::match_default);
1195
1196 // [7.12.1] Class template regex_iterator
1197 template <class BidirectionalIterator,
1198 class charT = typename iterator_traits<BidirectionalIterator>::value_type,
1199 class traits = regex_traits<charT> >
1200 class regex_iterator;
1201
1202 typedef regex_iterator<const char*> cregex_iterator;
1203 typedef regex_iterator<const wchar_t*> wcregex_iterator;
1204 typedef regex_iterator<string::const_iterator> sregex_iterator;
1205 typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
1206
1207 // [7.12.2] Class template regex_token_iterator
1208 template <class BidirectionalIterator,
1209 class charT = typename iterator_traits<BidirectionalIterator>::value_type,
1210 class traits = regex_traits<charT> >
1211 class regex_token_iterator;
1212
1213 typedef regex_token_iterator<const char*> cregex_token_iterator;
1214 typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
1215 typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
1216 typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
1217
1218 } // namespace tr1
1219 } // namespace std
1220
1221
1222[*Configuration:]
1223[@../../libs/config/index.html Boost.Config] should (automatically) define
1224the macro BOOST_HAS_TR1_REGEX if your
1225standard library implements this part of TR1.
1226
1227[*Standard Conformity:]
1228No known problems.
1229
1230[endsect]
1231
1232[section:complex Complex Number Algorithm Overloads.]
1233
1234 #include <boost/tr1/complex.hpp>
1235
1236or
1237
1238 #include <complex>
1239
1240The following function templates have additional overloads:
1241`arg`, `norm`, `conj`, `polar`, `imag`, and `real`.
1242
1243The additional
1244overloads are sufficient to ensure:
1245
1246*If the argument has type `long double`, then the overload behaves as if
1247the argument had been cast to `std::complex<long double>`.
1248*Otherwise, if the argument has type `double` or is an integer type,
1249then the overload behaves as if
1250the argument had been cast to `std::complex<double>`.
1251*Otherwise, if the argument has type `float`, then the overload
1252behaves as if
1253the argument had been cast to `std::complex<float>`.
1254
1255The function template `pow` has additional overloads sufficient to ensure,
1256for a call with at least one argument of type `std::complex<T>`:
1257
1258*If either argument has type `complex<long double>` or type
1259`long double`, then the overload behaves as if both arguments were cast
1260to `std::complex<long double>`
1261*Otherwise, if either argument has type `complex<double>`, `double`,
1262or an integer type, then the overload behaves as if both arguments were cast
1263to `std::complex<double>`
1264*Otherwise, if either argument has type `complex<float>` or `float`,
1265then the overload behaves as if both arguments were cast
1266to `std::complex<float>`
1267
1268In the following synopsis, `Real` is a floating point type,
1269`Arithmetic` is an integer or floating point type, and `
1270PROMOTE(X1 ... XN)` is the largest floating point type in the list
1271X1 to XN, after any non-floating point types in the list have been replaced by
1272the type `double`.
1273
1274 template <class Arithmetic>
1275 PROMOTE(Arithmetic) arg(const Arithmetic& t);
1276
1277 template <class Arithmetic>
1278 PROMOTE(Arithmetic) norm(const Arithmetic& t);
1279
1280 template <class Arithmetic>
1281 complex<PROMOTE(Arithmetic)> conj(const Arithmetic& t);
1282
1283 template <class Arithmetic1, class Arithmetic2>
1284 complex<PROMOTE(Arithmetic1,Arithmetic2)> polar(const Arithmetic1& rho, const Arithmetic2& theta = 0);
1285
1286 template <class Arithmetic>
1287 PROMOTE(Arithmetic) imag(const Arithmetic& );
1288
1289 template <class Arithmetic>
1290 PROMOTE(Arithmetic) real(const Arithmetic& t);
1291
1292 template<class Real1, class Real2>
1293 complex<PROMOTE(Real1, Real2)>
1294 pow(const complex<Real1>& x, const complex<Real2>& y);
1295
1296 template<class Real, class Arithmetic>
1297 complex<PROMOTE(Real, Arithmetic)>
1298 pow (const complex<Real>& x, const Arithmetic& y);
1299
1300 template<class Arithmetic, class Real>
1301 complex<PROMOTE(Real, Arithmetic)>
1302 pow (const Arithmetic& x, const complex<Real>& y);
1303
1304[*Configuration:]
1305[@../../libs/config/index.html Boost.Config] should (automatically) define
1306the macro BOOST_HAS_TR1_COMPLEX_OVERLOADS if your
1307standard library implements the additional overloads for the existing
1308complex arithmetic functions.
1309
1310[*Standard Conformity:]
1311No known problems.
1312
1313[endsect]
1314
1315[section:complex_trig Complex Number Additional Algorithms.]
1316
1317 #include <boost/tr1/complex.hpp>
1318
1319or
1320
1321 #include <complex>
1322
1323The algorithms `acos`, `asin`, `atan`,
1324`acosh`, `asinh`, `atanh` and `fabs`
1325are overloaded
1326for arguments of type `std::complex<T>`.
1327These algorithms are entirely
1328classical, and behave as specified in the C99 standard section 7.3.5.
1329See the [@../../libs/math/doc/html/inverse_complex.html
1330Boost.Math documentation for more information].
1331
1332 namespace std {
1333 namespace tr1 {
1334
1335 template<class T> complex<T> acos(complex<T>& x);
1336 template<class T> complex<T> asin(complex<T>& x);
1337 template<class T> complex<T> atan(complex<T>& x);
1338 template<class T> complex<T> acosh(complex<T>& x);
1339 template<class T> complex<T> asinh(complex<T>& x);
1340 template<class T> complex<T> atanh(complex<T>& x);
1341 template<class T> complex<T> fabs(complex<T>& x);
1342
1343 } // namespace tr1
1344 } // namespace std
1345
1346[*Configuration:]
1347[@../../libs/config/index.html Boost.Config] should (automatically) define
1348the macro BOOST_HAS_TR1_COMPLEX_INVERSE_TRIG
1349if your standard library implements the additional inverse trig functions.
1350
1351[*Standard Conformity:]
1352No known problems.
1353
1354[endsect]
1355
1356[section:unordered_set Unordered Associative Set (Hash Table).]
1357
1358 #include <boost/tr1/unordered_set.hpp>
1359
1360or
1361
1362 #include <unordered_set>
1363
1364For accessing data based on key lookup, the C++ standard library
1365offers std::set, std::map, std::multiset and std::multimap.
1366These are generally implemented using balanced binary trees so that
1367lookup time has logarithmic complexity. That is generally okay,
1368but in many cases a hash table can perform better, as accessing
1369data has constant complexity, on average. The worst case complexity
1370is linear, but that occurs rarely and with some care, can be avoided.
1371
1372With this in mind, the C++ Standard Library Technical Report
1373introduced the unordered associative containers, which are
1374implemented using hash tables, and they have now been added to
1375the Working Draft of the C++ Standard.
1376
1377Refer to the
1378[@../../libs/unordered/index.html Unordered Library docs]
1379for more information.
1380
1381 namespace std {
1382 namespace tr1 {
1383
1384 template <class Value,
1385 class Hash = hash<Value>,
1386 class Pred = std::equal_to<Value>,
1387 class Alloc = std::allocator<Value> >
1388 class unordered_set;
1389
1390 // [6.3.4.5] Class template unordered_multiset
1391 template <class Value,
1392 class Hash = hash<Value>,
1393 class Pred = std::equal_to<Value>,
1394 class Alloc = std::allocator<Value> >
1395 class unordered_multiset;
1396
1397 template <class Value, class Hash, class Pred, class Alloc>
1398 void swap(unordered_set<Value, Hash, Pred, Alloc>& x,
1399 unordered_set<Value, Hash, Pred, Alloc>& y);
1400
1401 template <class Value, class Hash, class Pred, class Alloc>
1402 void swap(unordered_multiset<Value, Hash, Pred, Alloc>& x,
1403 unordered_multiset<Value, Hash, Pred, Alloc>& y);
1404
1405 } // namespace tr1
1406 } // namespace std
1407
1408[*Configuration:]
1409[@../../libs/config/index.html Boost.Config] should (automatically) define
1410the macro BOOST_HAS_TR1_UNORDERED_SET if your
1411standard library implements this part of TR1.
1412
1413[*Standard Conformity:]
1414No known issues for conforming compilers.
1415
1416[endsect]
1417
1418[section:unordered_map Unordered Associative Map (Hash Table).]
1419
1420 #include <boost/tr1/unordered_map.hpp>
1421
1422or
1423
1424 #include <unordered_map>
1425
1426For accessing data based on key lookup, the C++ standard library
1427offers std::set, std::map, std::multiset and std::multimap.
1428These are generally implemented using balanced binary trees so that
1429lookup time has logarithmic complexity. That is generally okay,
1430but in many cases a hash table can perform better, as accessing
1431data has constant complexity, on average. The worst case complexity
1432is linear, but that occurs rarely and with some care, can be avoided.
1433
1434With this in mind, the C++ Standard Library Technical Report
1435introduced the unordered associative containers, which are
1436implemented using hash tables, and they have now been added to
1437the Working Draft of the C++ Standard.
1438
1439Refer to the
1440[@../../libs/unordered/index.html Unordered Library docs]
1441for more information.
1442
1443 namespace std {
1444 namespace tr1 {
1445
1446 // [6.3.4.4] Class template unordered_map
1447 template <class Key,
1448 class T,
1449 class Hash = hash<Key>,
1450 class Pred = std::equal_to<Key>,
1451 class Alloc = std::allocator<std::pair<const Key, T> > >
1452 class unordered_map;
1453
1454 // [6.3.4.6] Class template unordered_multimap
1455 template <class Key,
1456 class T,
1457 class Hash = hash<Key>,
1458 class Pred = std::equal_to<Key>,
1459 class Alloc = std::allocator<std::pair<const Key, T> > >
1460 class unordered_multimap;
1461
1462 template <class Key, class T, class Hash, class Pred, class Alloc>
1463 void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x,
1464 unordered_map<Key, T, Hash, Pred, Alloc>& y);
1465
1466 template <class Key, class T, class Hash, class Pred, class Alloc>
1467 void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
1468 unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
1469
1470 } // namespace tr1
1471 } // namespace std
1472
1473[*Configuration:]
1474[@../../libs/config/index.html Boost.Config] should (automatically) define
1475the macro BOOST_HAS_TR1_UNORDERED_MAP if your
1476standard library implements this part of TR1.
1477
1478[*Standard Conformity:]
1479No known issues for conforming compilers.
1480
1481[endsect]
1482
1483[section:special Mathematical Special Functions.]
1484
1485The TR adds 23 special functions (plus float and long double overloads)
1486to header <cmath>.
1487
1488Refer to the
1489[@../../libs/math/doc/html/math_toolkit/main_tr1.html Math Library docs]
1490for more information.
1491
1492
1493 namespace std {
1494 namespace tr1 {
1495
1496 // [5.2.1.1] associated Laguerre polynomials:
1497 double assoc_laguerre(unsigned n, unsigned m, double x);
1498 float assoc_laguerref(unsigned n, unsigned m, float x);
1499 long double assoc_laguerrel(unsigned n, unsigned m, long double x);
1500
1501 // [5.2.1.2] associated Legendre functions:
1502 double assoc_legendre(unsigned l, unsigned m, double x);
1503 float assoc_legendref(unsigned l, unsigned m, float x);
1504 long double assoc_legendrel(unsigned l, unsigned m, long double x);
1505
1506 // [5.2.1.3] beta function:
1507 double beta(double x, double y);
1508 float betaf(float x, float y);
1509 long double betal(long double x, long double y);
1510
1511 // [5.2.1.4] (complete) elliptic integral of the first kind:
1512 double comp_ellint_1(double k);
1513 float comp_ellint_1f(float k);
1514 long double comp_ellint_1l(long double k);
1515
1516 // [5.2.1.5] (complete) elliptic integral of the second kind:
1517 double comp_ellint_2(double k);
1518 float comp_ellint_2f(float k);
1519 long double comp_ellint_2l(long double k);
1520
1521 // [5.2.1.6] (complete) elliptic integral of the third kind:
1522 double comp_ellint_3(double k, double nu);
1523 float comp_ellint_3f(float k, float nu);
1524 long double comp_ellint_3l(long double k, long double nu);
1525
1526 // [5.2.1.7] confluent hypergeometric functions:
1527 double conf_hyperg(double a, double c, double x);
1528 float conf_hypergf(float a, float c, float x);
1529 long double conf_hypergl(long double a, long double c, long double x);
1530
1531 // [5.2.1.8] regular modified cylindrical Bessel functions:
1532 double cyl_bessel_i(double nu, double x);
1533 float cyl_bessel_if(float nu, float x);
1534 long double cyl_bessel_il(long double nu, long double x);
1535
1536 // [5.2.1.9] cylindrical Bessel functions (of the first kind):
1537 double cyl_bessel_j(double nu, double x);
1538 float cyl_bessel_jf(float nu, float x);
1539 long double cyl_bessel_jl(long double nu, long double x);
1540
1541 // [5.2.1.10] irregular modified cylindrical Bessel functions:
1542 double cyl_bessel_k(double nu, double x);
1543 float cyl_bessel_kf(float nu, float x);
1544 long double cyl_bessel_kl(long double nu, long double x);
1545
1546 // [5.2.1.11] cylindrical Neumann functions;
1547 // cylindrical Bessel functions (of the second kind):
1548 double cyl_neumann(double nu, double x);
1549 float cyl_neumannf(float nu, float x);
1550 long double cyl_neumannl(long double nu, long double x);
1551
1552 // [5.2.1.12] (incomplete) elliptic integral of the first kind:
1553 double ellint_1(double k, double phi);
1554 float ellint_1f(float k, float phi);
1555 long double ellint_1l(long double k, long double phi);
1556
1557 // [5.2.1.13] (incomplete) elliptic integral of the second kind:
1558 double ellint_2(double k, double phi);
1559 float ellint_2f(float k, float phi);
1560 long double ellint_2l(long double k, long double phi);
1561
1562 // [5.2.1.14] (incomplete) elliptic integral of the third kind:
1563 double ellint_3(double k, double nu, double phi);
1564 float ellint_3f(float k, float nu, float phi);
1565 long double ellint_3l(long double k, long double nu, long double phi);
1566
1567 // [5.2.1.15] exponential integral:
1568 double expint(double x);
1569 float expintf(float x);
1570 long double expintl(long double x);
1571
1572 // [5.2.1.16] Hermite polynomials:
1573 double hermite(unsigned n, double x);
1574 float hermitef(unsigned n, float x);
1575 long double hermitel(unsigned n, long double x);
1576
1577 // [5.2.1.17] hypergeometric functions:
1578 double hyperg(double a, double b, double c, double x);
1579 float hypergf(float a, float b, float c, float x);
1580 long double hypergl(long double a, long double b, long double c, long double x);
1581
1582 // [5.2.1.18] Laguerre polynomials:
1583 double laguerre(unsigned n, double x);
1584 float laguerref(unsigned n, float x);
1585 long double laguerrel(unsigned n, long double x);
1586
1587 // [5.2.1.19] Legendre polynomials:
1588 double legendre(unsigned l, double x);
1589 float legendref(unsigned l, float x);
1590 long double legendrel(unsigned l, long double x);
1591
1592 // [5.2.1.20] Riemann zeta function:
1593 double riemann_zeta(double);
1594 float riemann_zetaf(float);
1595 long double riemann_zetal(long double);
1596
1597 // [5.2.1.21] spherical Bessel functions (of the first kind):
1598 double sph_bessel(unsigned n, double x);
1599 float sph_besself(unsigned n, float x);
1600 long double sph_bessell(unsigned n, long double x);
1601
1602 // [5.2.1.22] spherical associated Legendre functions:
1603 double sph_legendre(unsigned l, unsigned m, double theta);
1604 float sph_legendref(unsigned l, unsigned m, float theta);
1605 long double sph_legendrel(unsigned l, unsigned m, long double theta);
1606
1607 // [5.2.1.23] spherical Neumann functions;
1608 // spherical Bessel functions (of the second kind):
1609 double sph_neumann(unsigned n, double x);
1610 float sph_neumannf(unsigned n, float x);
1611 long double sph_neumannl(unsigned n, long double x);
1612
1613 } // namespace tr1
1614 } // namespace std
1615
1616
1617[*Standard Conformity:]
1618The following functions are not supported in the Boost version of this component:
1619
1620 // [5.2.1.7] confluent hypergeometric functions:
1621 double conf_hyperg(double a, double c, double x);
1622 float conf_hypergf(float a, float c, float x);
1623 long double conf_hypergl(long double a, long double c, long double x);
1624
1625 // [5.2.1.17] hypergeometric functions:
1626 double hyperg(double a, double b, double c, double x);
1627 float hypergf(float a, float b, float c, float x);
1628 long double hypergl(long double a, long double b, long double c, long double x);
1629
1630[endsect]
1631
1632[section:c99_special C99 Mathematical Special Functions.]
1633
1634The TR adds a number of special functions which were first introduced in the C99 standard
1635to header <cmath>.
1636
1637Refer to the
1638[@../../libs/math/doc/html/math_toolkit/main_tr1.html Math Library docs]
1639for more information.
1640
1641
1642 namespace std {
1643 namespace tr1 {
1644
1645 // types
1646 typedef floating-type double_t;
1647 typedef floating-type float_t;
1648
1649 // functions
1650 double acosh(double x);
1651 float acoshf(float x);
1652 long double acoshl(long double x);
1653
1654 double asinh(double x);
1655 float asinhf(float x);
1656 long double asinhl(long double x);
1657
1658 double atanh(double x);
1659 float atanhf(float x);
1660 long double atanhl(long double x);
1661
1662 double cbrt(double x);
1663 float cbrtf(float x);
1664 long double cbrtl(long double x);
1665
1666 double copysign(double x, double y);
1667 float copysignf(float x, float y);
1668 long double copysignl(long double x, long double y);
1669
1670 double erf(double x);
1671 float erff(float x);
1672 long double erfl(long double x);
1673
1674 double erfc(double x);
1675 float erfcf(float x);
1676 long double erfcl(long double x);
1677
1678 double exp2(double x);
1679 float exp2f(float x);
1680 long double exp2l(long double x);
1681
1682 double expm1(double x);
1683 float expm1f(float x);
1684 long double expm1l(long double x);
1685
1686 double fdim(double x, double y);
1687 float fdimf(float x, float y);
1688 long double fdiml(long double x, long double y);
1689
1690 double fma(double x, double y, double z);
1691 float fmaf(float x, float y, float z);
1692 long double fmal(long double x, long double y, long double z);
1693
1694 double fmax(double x, double y);
1695 float fmaxf(float x, float y);
1696 long double fmaxl(long double x, long double y);
1697
1698 double fmin(double x, double y);
1699 float fminf(float x, float y);
1700 long double fminl(long double x, long double y);
1701
1702 double hypot(double x, double y);
1703 float hypotf(float x, float y);
1704 long double hypotl(long double x, long double y);
1705
1706 int ilogb(double x);
1707 int ilogbf(float x);
1708 int ilogbl(long double x);
1709
1710 double lgamma(double x);
1711 float lgammaf(float x);
1712 long double lgammal(long double x);
1713
1714 long long llrint(double x);
1715 long long llrintf(float x);
1716 long long llrintl(long double x);
1717
1718 long long llround(double x);
1719 long long llroundf(float x);
1720 long long llroundl(long double x);
1721
1722 double log1p(double x);
1723 float log1pf(float x);
1724 long double log1pl(long double x);
1725
1726 double log2(double x);
1727 float log2f(float x);
1728 long double log2l(long double x);
1729
1730 double logb(double x);
1731 float logbf(float x);
1732 long double logbl(long double x);
1733
1734 long lrint(double x);
1735 long lrintf(float x);
1736 long lrintl(long double x);
1737
1738 long lround(double x);
1739 long lroundf(float x);
1740 long lroundl(long double x);
1741
1742 double nan(const char *str);
1743 float nanf(const char *str);
1744 long double nanl(const char *str);
1745
1746 double nearbyint(double x);
1747 float nearbyintf(float x);
1748 long double nearbyintl(long double x);
1749
1750 double nextafter(double x, double y);
1751 float nextafterf(float x, float y);
1752 long double nextafterl(long double x, long double y);
1753
1754 double nexttoward(double x, long double y);
1755 float nexttowardf(float x, long double y);
1756 long double nexttowardl(long double x, long double y);
1757
1758 double remainder(double x, double y);
1759 float remainderf(float x, float y);
1760 long double remainderl(long double x, long double y);
1761
1762 double remquo(double x, double y, int *pquo);
1763 float remquof(float x, float y, int *pquo);
1764 long double remquol(long double x, long double y, int *pquo);
1765
1766 double rint(double x);
1767 float rintf(float x);
1768 long double rintl(long double x);
1769
1770 double round(double x);
1771 float roundf(float x);
1772 long double roundl(long double x);
1773
1774 double scalbln(double x, long ex);
1775 float scalblnf(float x, long ex);
1776 long double scalblnl(long double x, long ex);
1777 double scalbn(double x, int ex);
1778 float scalbnf(float x, int ex);
1779 long double scalbnl(long double x, int ex);
1780
1781 double tgamma(double x);
1782 float tgammaf(float x);
1783 long double tgammal(long double x);
1784
1785 double trunc(double x);
1786 float truncf(float x);
1787 long double truncl(long double x);
1788
1789 // C99 macros defined as C++ templates
1790 template<class T> bool signbit(T x);
1791 template<class T> int fpclassify(T x);
1792 template<class T> bool isfinite(T x);
1793 template<class T> bool isinf(T x);
1794 template<class T> bool isnan(T x);
1795 template<class T> bool isnormal(T x);
1796 template<class T> bool isgreater(T x, T y);
1797 template<class T> bool isgreaterequal(T x, T y);
1798 template<class T> bool isless(T x, T y);
1799 template<class T> bool islessequal(T x, T y);
1800 template<class T> bool islessgreater(T x, T y);
1801 template<class T> bool isunordered(T x, T y);
1802
1803 }} // namespaces
1804
1805[*Standard Conformity:]
1806The following functions are not supported in the Boost version of this component:
1807
1808 double exp2(double x);
1809 float exp2f(float x);
1810 long double exp2l(long double x);
1811
1812 double fdim(double x, double y);
1813 float fdimf(float x, float y);
1814 long double fdiml(long double x, long double y);
1815
1816 double fma(double x, double y, double z);
1817 float fmaf(float x, float y, float z);
1818 long double fmal(long double x, long double y, long double z);
1819
1820 int ilogb(double x);
1821 int ilogbf(float x);
1822 int ilogbl(long double x);
1823
1824 long long llrint(double x);
1825 long long llrintf(float x);
1826 long long llrintl(long double x);
1827
1828 double log2(double x);
1829 float log2f(float x);
1830 long double log2l(long double x);
1831
1832 double logb(double x);
1833 float logbf(float x);
1834 long double logbl(long double x);
1835
1836 long lrint(double x);
1837 long lrintf(float x);
1838 long lrintl(long double x);
1839
1840 double nan(const char *str);
1841 float nanf(const char *str);
1842 long double nanl(const char *str);
1843
1844 double nearbyint(double x);
1845 float nearbyintf(float x);
1846 long double nearbyintl(long double x);
1847
1848 double remainder(double x, double y);
1849 float remainderf(float x, float y);
1850 long double remainderl(long double x, long double y);
1851
1852 double remquo(double x, double y, int *pquo);
1853 float remquof(float x, float y, int *pquo);
1854 long double remquol(long double x, long double y, int *pquo);
1855
1856 double rint(double x);
1857 float rintf(float x);
1858 long double rintl(long double x);
1859
1860 double scalbln(double x, long ex);
1861 float scalblnf(float x, long ex);
1862 long double scalblnl(long double x, long ex);
1863 double scalbn(double x, int ex);
1864 float scalbnf(float x, int ex);
1865 long double scalbnl(long double x, int ex);
1866
1867 // C99 macros defined as C++ templates
1868 template<class T> bool isgreater(T x, T y);
1869 template<class T> bool isgreaterequal(T x, T y);
1870 template<class T> bool isless(T x, T y);
1871 template<class T> bool islessequal(T x, T y);
1872 template<class T> bool islessgreater(T x, T y);
1873 template<class T> bool isunordered(T x, T y);
1874
1875[endsect]
1876[endsect]
1877
1878[section:header_list TR1 By Header]
1879
1880[section:array_header <array>]
1881
1882See: [link boost_tr1.subject_list.array Fixed Size Array]
1883
1884[endsect]
1885
1886[section:cmath_header <cmath>]
1887
1888See: [link boost_tr1.subject_list.special Special Functions]
1889
1890See: [link boost_tr1.subject_list.c99_special C99 Special Functions]
1891
1892[endsect]
1893
1894[section:complex_header <complex>]
1895
1896See: [link boost_tr1.subject_list.complex Additional Overloads for Complex Number Algorithms]
1897
1898See: [link boost_tr1.subject_list.complex_trig Additional Complex Number Algorithms]
1899
1900[endsect]
1901
1902[section:functional <functional>]
1903
1904See: [link boost_tr1.subject_list.ref Reference Wrapper].
1905
1906See: [link boost_tr1.subject_list.result_of Result_of].
1907
1908See: [link boost_tr1.subject_list.mem_fn Member Function Wrappers].
1909
1910See: [link boost_tr1.subject_list.bind Function Binders].
1911
1912See: [link boost_tr1.subject_list.function Polymorphic Function Wrappers].
1913
1914See: [link boost_tr1.subject_list.hash Hash Functions].
1915
1916[endsect]
1917
1918[section:memory <memory>]
1919
1920See: [link boost_tr1.subject_list.ptrs Smart Pointers].
1921
1922[endsect]
1923
1924[section:random_header <random>]
1925
1926See: [link boost_tr1.subject_list.random Random Numbers].
1927
1928[endsect]
1929
1930[section:regex_header <regex>]
1931
1932See: [link boost_tr1.subject_list.regex Regular Expressions].
1933
1934[endsect]
1935
1936[section:tuple_header <tuple>]
1937
1938See: [link boost_tr1.subject_list.tuple Tuple Types].
1939
1940[endsect]
1941
1942[section:type_traits_header <type_traits>]
1943
1944See: [link boost_tr1.subject_list.type_traits Type Traits].
1945
1946[endsect]
1947
1948[section:unordered_map_header <unordered_map>]
1949
1950See: [link boost_tr1.subject_list.unordered_map Unordered Associative Map]
1951
1952[endsect]
1953
1954[section:unordered_set_header <unordered_set>]
1955
1956See: [link boost_tr1.subject_list.unordered_set Unordered Associative Set].
1957
1958[endsect]
1959
1960[section:utility_header <utility>]
1961
1962See: [link boost_tr1.subject_list.utility Tuple Interface to std::pair].
1963
1964[endsect]
1965
1966[endsect]
1967
1968[section:implementation Implementation]
1969
1970When Boost.TR1 is [link boost_tr1.config configured] to make use of your standard library's
1971native TR1 implementation, then it doesn't do very much: it just includes
1972the appropriate header.
1973
1974When Boost.TR1 is using the Boost implementation of a particular
1975component, then it includes the appropriate Boost header(s) and imports
1976the necessary declarations in `namespace std::tr1` with using declarations.
1977Note that only those declarations that are part of the standard are imported:
1978the implementation is deliberately quite strict about not including any
1979Boost-specific extensions in `namespace std::tr1`, in order to catch any
1980portability errors in user code. If you really need to use Boost-specific
1981extensions then you should include the Boost headers directly and use the
1982declarations in `namespace boost::` instead. Note that this style of implementation
1983is not completely standards-conforming, in particular it is not possible
1984to add user-defined template specializations of TR1 components
1985into `namespace std::tr1`. There are also one or two Boost libraries that are not
1986yet fully standards conforming, any such non-conformities are documented in
1987[link boost_tr1.subject_list the TR1 by subject section]. Hopefully, occurrences of non-standard
1988behavior should be extremely rare in practice however.
1989
1990If you use the standard conforming header includes (in `boost/tr1/tr1`)
1991then these header names can sometimes conflict with existing standard library
1992headers (for example `shared_ptr` is added to the existing
1993standard library header
1994`<memory>` rather than it's own header). These headers
1995forward on to your existing standard library header in one of two ways: for
1996gcc it uses `#include_next`, and for other compilers it uses the
1997macro `BOOST_TR1_STD_HEADER(header)` (defined in
1998[@../../boost/tr1/detail/config.hpp boost/tr1/detail/config.hpp])
1999which evaluates to `#include <../include/header>`. This
2000should work "straight out the box" for most compilers, but does mean that
2001these headers should [*never] be placed inside a
2002directory called "include"
2003that is already in your compiler's search path.
2004
2005[endsect]
2006
2007
2008[section:testing Testing]
2009
2010The test suite for Boost.TR1 is relatively lightweight; tests have been
2011added to the Boost.Config test suite for each new configuration macro, and
2012each TR1 component has a very short concept check test added. The concept test
2013programs are designed only to verify that all the TR1 components
2014that are
2015supposed to be in `namespace std::tr1` are indeed present and have standards
2016conforming interfaces. There are a few test programs (those which end in the suffix
2017"_tricky") which do not currently compile with the Boost.TR1 implementation, because the
2018relevant Boost libraries have not yet implemented the features tested; hopefully
2019these incompatibilities will be removed in future releases.
2020
2021The concept tests do not take account of compiler defects (quite deliberately
2022so); the intent is that the tests can be used to verify conformance with the
2023standard, both for Boost code, and for third party implementations. Consequently
2024very many of these tests are known to fail with older compilers. This should
2025not be taken as evidence that these compilers can not be used at all with Boost.TR1,
2026simply that there are features missing that make those compilers non-conforming.
2027
2028Full runtime tests for TR1 components are not in general part of this
2029test suite, however, it is hoped that the Boost.TR1 component authors will make
2030their regular test suites compile with the standards conforming headers as well
2031as the Boost-specific ones. This will allow these tests to be used against the standard
2032library's own TR1 implementation as well as the Boost one.
2033
2034[endsect]
2035
2036
2037
2038
2039