Professional Documents
Culture Documents
Boost - An Overview: Advanced C++ Programming
Boost - An Overview: Advanced C++ Programming
Conclusion
References
Boost - An overview
Advanced C++ Programming
Thomas Heller
1/ 20
What is Boost?
Conclusion
References
What is Boost?
Conclusion
2/ 20
What is Boost?
Conclusion
References
Boost is ...
3/ 20
What is Boost?
Conclusion
References
Boost is ...
3/ 20
What is Boost?
Conclusion
References
Boost is ...
3/ 20
What is Boost?
Conclusion
References
Boost is ...
3/ 20
What is Boost?
Conclusion
References
Libraries List
4/ 20
What is Boost?
Conclusion
References
Libraries List
Containers
Iterators
Algorithms
Data structures
Image processing
Input/Output
higher-order programming
Inter-language support
Generic Programming
Memory
Template Metaprogramming
Parsing
Preprocessor
Programming Interfaces
Miscellaneous
Metaprogramming
Concurrent Programming
What is Boost?
Conclusion
References
Libraries List
accumulators
any
array
asio
assign
bimap
bind and mem_fn
call_traits
chrono
circular_buer
compatibility
compressed_pair
concept check
cong
conversion
crc
date_time
dynamic_bitset
exception
enable_if
lesystem
yweight
foreach
format
function
function_types
functional
functional/factory
functional/forward
functional/hash
fusion
gil
geometry
graph
icl
integer
interprocess
interval
intrusive
in_place_factory
typed_in_place_factory
io state savers
iostreams
iterators
lambda
lexical_cast
math
math/complex number algorithms
math/common_factor
math/octonion
math/quaternion
math/special_functions
math/statistical distributions
minmax
MPI
mpl
smart_ptr
statechart
static_assert
spirit
string_algo
swap
system
test
thread
timer
tokenizer
TR1
tribool
tuple
type_traits
typeof
uBLAS
units
unordered
utility
value_initialized
uuid
variant
wave
xpressive
4/ 20
What is Boost?
Conclusion
References
array
regex
bind
result_of
chrono
smart_ptr
enable_if
static_assert
function
thread
range
tuple
ratio
type_traits
5/ 20
What is Boost?
Conclusion
References
type_traits
optional
and
mpl
6/ 20
What is Boost?
Conclusion
References
type_traits - Motivation
template < typename Iter1 , typename Iter2 >
Iter2 copy ( Iter1 first , Iter1 last , Iter2 out )
{
while ( first != last )
{
* out = * first ;
++ out ; ++ first ;
}
return out ;
}
Is this generic code the optimal solution?
7/ 20
What is Boost?
Conclusion
References
type_traits - Motivation
template < typename Iter1 , typename Iter2 >
Iter2 copy ( Iter1 first , Iter1 last , Iter2 out )
{
while ( first != last )
{
* out = * first ;
++ out ; ++ first ;
}
return out ;
}
Using memcpy could be even faster! If ...
7/ 20
What is Boost?
Conclusion
References
type_traits - Motivation
template < typename Iter1 , typename Iter2 >
Iter2 copy ( Iter1 first , Iter1 last , Iter2 out )
{
while ( first != last )
{
* out = * first ;
++ out ; ++ first ;
}
return out ;
}
Using memcpy could be even faster! If ...
1. ... Iter1 and Iter2 are pointers
2. ... Iter1 and Iter2 point to the same type
3. ... the type pointed to by Iter1 has a trivial assignment
operator
7/ 20
What is Boost?
Conclusion
References
type_traits
Return
8/ 20
What is Boost?
Conclusion
References
type_traits
Return
What is a Metafunction?
struct true_type
: bool_ < true >
{};
struct false_type
: bool_ < false >
{};
8/ 20
What is Boost?
Conclusion
References
type_traits
Return
What is a Metafunction?
struct true_type
: bool_ < true >
{};
struct false_type
: bool_ < false >
{};
8/ 20
What is Boost?
Conclusion
References
Return
Return
false_type otherwise
9/ 20
What is Boost?
Conclusion
References
Return
Return
false_type otherwise
9/ 20
What is Boost?
Conclusion
References
Return
Return
false_type otherwise
Template specialization
template <>
struct is_void<void>
: true_type
{};
9/ 20
What is Boost?
Conclusion
References
Return
Return
false_type otherwise
10/ 20
What is Boost?
Conclusion
References
Return
Return
false_type otherwise
10/ 20
What is Boost?
Conclusion
References
Return
Return
false_type otherwise
10/ 20
What is Boost?
Conclusion
References
Return
Return
false_type otherwise
What is Boost?
Conclusion
References
Return
Return
11/ 20
What is Boost?
Conclusion
References
Return
Return
11/ 20
What is Boost?
Conclusion
References
Return
Return
11/ 20
What is Boost?
Conclusion
References
http://www.boost.org/doc/libs/release/libs/type_
traits/doc/html/index.html
12/ 20
What is Boost?
Conclusion
References
http://www.boost.org/doc/libs/release/libs/type_
traits/doc/html/index.html
is_union
is_pod
has_trivial_constructor
has_trivial_copy
has_trivial_assign
has_trivial_destructor
has_nothrow_constructor
has_nothrow_copy
has_nothrow_assign
has_virtual_destructor
12/ 20
What is Boost?
Conclusion
References
http://www.boost.org/doc/libs/release/libs/type_
traits/doc/html/index.html
is_union
is_pod
has_trivial_constructor
has_trivial_copy
has_trivial_assign
has_trivial_destructor
has_nothrow_constructor
has_nothrow_copy
has_nothrow_assign
has_virtual_destructor
What is Boost?
Conclusion
References
return out ;
13/ 20
What is Boost?
Conclusion
References
13/ 20
What is Boost?
Conclusion
References
// 1.:
is_pointer < Iter1 >
is_pointer < Iter2 >
13/ 20
What is Boost?
Conclusion
References
// 2.:
typedef typename std :: iterator_traits < Iter1 >:: value_type
value_type1 ;
typedef typename std :: iterator_traits < Iter2 >:: value_type
value_type2 ;
is_same < value_type1 , value_type2 >
13/ 20
What is Boost?
Conclusion
References
// 3.:
typedef typename std :: iterator_traits < Iter1 >:: value_type
value_type ;
has_trivial_assign < value_type >
13/ 20
What is Boost?
Conclusion
References
// Combined , pseudocode
typedef typename std :: iterator_traits < Iter1 >:: value_type
value_type1 ;
typedef typename std :: iterator_traits < Iter2 >:: value_type
value_type2 ;
if ( is_pointer < Iter1 > && is_pointer < Iter2 >)
if ( is_same < value_type1 , value_type2 >)
if ( has_trivial_assign < value_type1 >)
return true_type ;
else
return false_type ;
else
return false_type ;
else
return false_type ;
13/ 20
What is Boost?
Conclusion
References
What is Boost?
Conclusion
References
What is Boost?
Conclusion
References
What is Boost?
Conclusion
References
What is Boost?
Conclusion
References
13/ 20
What is Boost?
Conclusion
References
What is Boost?
Conclusion
References
type_traits - So ...
14/ 20
What is Boost?
Conclusion
References
optional - Motivation
Consider these three functions:
1.
2.
char get_async_input();
3.
point polygon::get_any_point_inside();
15/ 20
What is Boost?
Conclusion
References
optional - Motivation
Consider these three functions:
1.
2.
char get_async_input();
3.
point polygon::get_any_point_inside();
15/ 20
What is Boost?
Conclusion
References
optional - Motivation
Consider these three functions:
1.
2.
char get_async_input();
3.
point polygon::get_any_point_inside();
Possible Solutions:
Assert
Exceptions
15/ 20
What is Boost?
Conclusion
References
optional - Motivation
Consider these three functions:
1.
2.
char get_async_input();
3.
point polygon::get_any_point_inside();
Possible Solutions:
Assert
Exceptions
Return
std::pair<T, bool>
15/ 20
What is Boost?
optional<T>
Conclusion
vs std::pair<T,
T can be anything
References
bool>
T must be
DefaultConstructable
16/ 20
What is Boost?
Conclusion
References
17/ 20
What is Boost?
Conclusion
References
17/ 20
What is Boost?
Conclusion
References
Don't reinvent the wheel, look what Boost has to oer for you!
17/ 20
What is Boost?
Conclusion
References
18/ 20
What is Boost?
Conclusion
References
Questions?
19/ 20
What is Boost?
Conclusion
References
http://www.boost.org
http:
//boost.org/doc/libs/release/libs/libraries.htm
http://www.boost.org/doc/libs/release/libs/type_
traits/doc/html/index.html
http://www.boost.org/doc/libs/1_46_1/libs/mpl/doc/
index.html
http://www.boost.org/doc/libs/release/libs/
optional/doc/html/index.html
20/ 20