Algorithm.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_UTIL_ALGORITHM_H_
36 #define _BLAZE_UTIL_ALGORITHM_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
45 #include <blaze/util/Types.h>
47 
48 
49 namespace blaze {
50 
51 //=================================================================================================
52 //
53 // TRANSFER
54 //
55 //=================================================================================================
56 
57 //*************************************************************************************************
69 template< typename InputIterator
70  , typename OutputIterator >
71 OutputIterator transfer( InputIterator first, InputIterator last, OutputIterator dest )
72 {
73  using ValueType = typename std::iterator_traits<InputIterator>::value_type;
74 
76  return std::move( first, last, dest );
77  }
78  else {
79  return std::copy( first, last, dest );
80  }
81 }
82 //*************************************************************************************************
83 
84 
85 
86 
87 //=================================================================================================
88 //
89 // POLYMORPHIC COUNT
90 //
91 //=================================================================================================
92 
93 //*************************************************************************************************
104 template< typename D // Dynamic type of the objects
105  , typename S > // Static type of the objects
106 inline size_t polymorphicCount( S *const * first, S *const * last )
107 {
109 
110  size_t count( 0 );
111  for( S *const * it=first; it!=last; ++it )
112  if( dynamic_cast<D*>( *it ) ) ++count;
113  return count;
114 }
115 //*************************************************************************************************
116 
117 
118 
119 
120 //=================================================================================================
121 //
122 // POLYMORPHIC FIND
123 //
124 //=================================================================================================
125 
126 //*************************************************************************************************
137 template< typename D // Dynamic type of the objects
138  , typename S > // Static type of the objects
139 inline S *const * polymorphicFind( S *const * first, S *const * last )
140 {
142 
143  while( first != last && !dynamic_cast<D*>( *first ) ) ++first;
144  return first;
145 }
146 //*************************************************************************************************
147 
148 } // namespace blaze
149 
150 #endif
Header file for basic type definitions.
size_t polymorphicCount(S *const *first, S *const *last)
Counts the pointer to objects with dynamic type D.
Definition: Algorithm.h:106
OutputIterator transfer(InputIterator first, InputIterator last, OutputIterator dest)
Transfers the elements from the given source range to the destination range.
Definition: Algorithm.h:71
#define BLAZE_CONSTRAINT_MUST_BE_STRICTLY_DERIVED_FROM(D, B)
Constraint on the inheritance relationship of a data type.In case D is not derived from B...
Definition: DerivedFrom.h:101
Compile time type check.The IsNothrowMoveAssignable type trait tests whether the expression.
Definition: IsAssignable.h:184
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
S *const * polymorphicFind(S *const *first, S *const *last)
Finds the next pointer to an object with dynamic type D.
Definition: Algorithm.h:139
Constraint on the inheritance relationship of a data type.
Header file for the IsAssignable type trait.