Commit 1ac160e9 authored by Ing. Jan Trávníček's avatar Ing. Jan Trávníček

drop dependency on non-standard libstdc++ features

parent b6d54d39
......@@ -127,7 +127,7 @@ public:
* \brief
* The underlying iterator within some list of children.
*/
typename ext::vector < forward_tree >::const_iterator node;
const forward_tree * node;
/**
* \brief
......@@ -154,7 +154,7 @@ public:
*
* \param n the iterator to child list
*/
const_structure_iterator ( typename ext::vector < forward_tree >::const_iterator n ) : node ( n ), parents ( ), virtual_node ( false ), isEnd ( false ) {
const_structure_iterator ( const forward_tree * n ) : node ( n ), parents ( ), virtual_node ( false ), isEnd ( false ) {
}
/**
......@@ -170,9 +170,9 @@ public:
const forward_tree * parent = parents.back ( );
if ( node == parent->getChildren ( ).end ( ) ) {
if ( std::distance ( & * parent->getChildren ( ).begin ( ), node ) == std::distance ( parent->getChildren ( ).begin ( ), parent->getChildren ( ).end ( ) ) ) { // just a way to detect node == end_of_children
parents.pop_back();
node = typename ext::vector < forward_tree >::const_iterator ( parent );
node = parent;
} else {
virtual_node = false;
}
......@@ -182,11 +182,9 @@ public:
isEnd = true;
}
} else {
typename ext::vector < forward_tree >::const_iterator newIter = node->getChildren ( ).begin ( );
if ( newIter != node->getChildren ( ).end ( ) ) {
parents.push_back ( & * node );
node = newIter;
if ( ! node->getChildren ( ).empty ( ) ) {
parents.push_back ( node );
node = & * node->getChildren ( ).begin ( );
} else {
virtual_node = true;
}
......@@ -220,12 +218,9 @@ public:
virtual_node = true;
isEnd = false;
} else if ( virtual_node ) {
typename ext::vector < forward_tree >::const_iterator newIter = node->getChildren ( ).end ( );
if ( newIter != node->getChildren ( ).begin ( ) ) {
parents.push_back ( & * node );
node = newIter;
--node;
if ( ! node->getChildren ( ).empty ( ) ) {
parents.push_back ( node );
node = & * -- node->getChildren ( ).end ( );
} else {
virtual_node = false;
}
......@@ -233,9 +228,9 @@ public:
if ( parents.size ( ) ) {
const forward_tree * parent = parents.back ( );
if ( node == parent->getChildren ( ).begin ( ) ) {
if ( node == & * parent->getChildren ( ).begin ( ) ) {
parents.pop_back();
node = typename ext::vector < forward_tree >::const_iterator ( parent );
node = parent;
} else {
--node;
virtual_node = true;
......@@ -347,7 +342,7 @@ public:
*
* \param n the iterator to child list
*/
const_prefix_iterator ( typename ext::vector < forward_tree >::const_iterator n ) : node ( n ) {
const_prefix_iterator ( const forward_tree * n ) : node ( n ) {
}
/**
......@@ -478,7 +473,7 @@ public:
*
* \param n the iterator to child list
*/
const_postfix_iterator ( typename ext::vector < forward_tree >::const_iterator n ) : node ( n ) {
const_postfix_iterator ( const forward_tree * n ) : node ( n ) {
}
/**
......@@ -799,7 +794,7 @@ public:
* \return prefix iterator to the root
*/
const_prefix_iterator prefix_begin ( ) const {
return typename ext::vector < forward_tree >::const_iterator ( this );
return const_prefix_iterator ( this );
}
/**
......@@ -809,7 +804,7 @@ public:
* \return prefix iterator one after the last node in the prefix traversal
*/
const_prefix_iterator prefix_end ( ) const {
const_prefix_iterator res ( typename ext::vector < forward_tree >::const_iterator ( this + 1 ) );
const_prefix_iterator res ( this + 1 );
res.node.isEnd = true;
return res;
......@@ -824,7 +819,7 @@ public:
* \return prefix iterator to the first node in the postfix traversal
*/
const_postfix_iterator postfix_begin ( ) const {
const_postfix_iterator res { typename ext::vector < forward_tree >::const_iterator ( this ) };
const_postfix_iterator res ( this );
while ( ! res.node.getVirtual ( ) ) ++res.node;
......@@ -838,7 +833,7 @@ public:
* \return prefix iterator one after the last node in the postfix traversal
*/
const_postfix_iterator postfix_end ( ) const {
const_postfix_iterator res ( typename ext::vector < forward_tree >::const_iterator ( this + 1 ) );
const_postfix_iterator res ( this + 1 );
res.node.isEnd = true;
return res;
......@@ -853,7 +848,7 @@ public:
* \return prefix iterator to the first node in the traversal
*/
const_structure_iterator structure_begin ( ) const {
return typename ext::vector < forward_tree >::const_iterator ( this );
return const_structure_iterator ( this );
}
/**
......@@ -863,7 +858,7 @@ public:
* \return prefix iterator to one after the last node in the traversal
*/
const_structure_iterator structure_end ( ) const {
const_structure_iterator res ( typename ext::vector < forward_tree >::const_iterator ( this + 1 ) );
const_structure_iterator res ( this + 1 );
res.isEnd = true;
return res;
......
......@@ -79,11 +79,10 @@ public:
};
template<typename _T1, typename _T2>
constexpr ext::pair < typename std::__decay_and_strip < _T1 >::__type, typename std::__decay_and_strip < _T2 >::__type > make_pair ( _T1 && __x, _T2 && __y ) {
typedef typename std::__decay_and_strip < _T1 >::__type __ds_type1;
typedef typename std::__decay_and_strip < _T2 >::__type __ds_type2;
typedef pair < __ds_type1, __ds_type2 > __pair_type;
return __pair_type ( std::forward < _T1 > ( __x ), std::forward < _T2 > ( __y ) );
constexpr auto make_pair ( _T1 && __x, _T2 && __y ) {
typedef typename ext::strip_reference_wrapper < std::decay_t < _T1 > >::type __ds_type1;
typedef typename ext::strip_reference_wrapper < std::decay_t < _T2 > >::type __ds_type2;
return pair < __ds_type1, __ds_type2 > ( std::forward < _T1 > ( __x ), std::forward < _T2 > ( __y ) );
}
/**
......
......@@ -479,9 +479,8 @@ namespace ext {
* \result pointer tuple containing values from arguments
*/
template < typename... _Elements >
constexpr ptr_tuple < typename std::__decay_and_strip < _Elements >::__type... > make_ptr_tuple ( _Elements && ... __args ) {
typedef ptr_tuple < typename std::__decay_and_strip < _Elements >::__type... > __result_type;
return __result_type ( std::forward < _Elements > ( __args ) ... );
constexpr auto make_ptr_tuple ( _Elements && ... __args ) {
return ptr_tuple < typename ext::strip_reference_wrapper < std::decay_t < _Elements > >::type ... > ( std::forward < _Elements > ( __args ) ... );
}
} /* namespace ext */
......
......@@ -152,7 +152,7 @@ public:
* \brief
* The underlying iterator within some list of children.
*/
typename ext::vector < tree >::const_iterator node;
const tree * node;
/**
* \brief
......@@ -179,7 +179,7 @@ public:
*
* \param n the iterator to child list
*/
const_structure_iterator ( typename ext::vector < tree >::const_iterator n ) : node ( n ), level ( 0 ), virtual_node ( false ), isEnd ( false ) {
const_structure_iterator ( const tree * n ) : node ( n ), level ( 0 ), virtual_node ( false ), isEnd ( false ) {
}
/**
......@@ -194,9 +194,9 @@ public:
++node;
if ( parent != nullptr ) {
if ( node == parent->getChildren ( ).end ( ) ) {
if ( std::distance ( & * parent->getChildren ( ).begin ( ), node ) == std::distance ( parent->getChildren ( ).begin ( ), parent->getChildren ( ).end ( ) ) ) { // just a way to detect node == end_of_children
--level;
node = typename ext::vector < tree >::const_iterator ( parent );
node = parent;
} else {
virtual_node = false;
}
......@@ -205,11 +205,9 @@ public:
isEnd = true;
}
} else {
typename ext::vector < tree >::const_iterator newIter = node->getChildren ( ).begin ( );
if ( newIter != node->getChildren ( ).end ( ) ) {
if ( ! node->getChildren ( ).empty ( ) ) {
++level;
node = newIter;
node = & * node->getChildren ( ).begin ( );
} else {
virtual_node = true;
}
......@@ -243,12 +241,10 @@ public:
virtual_node = true;
isEnd = false;
} else if ( virtual_node ) {
typename ext::vector < tree >::const_iterator newIter = node->getChildren ( ).end ( );
if ( newIter != node->getChildren ( ).begin ( ) ) {
if ( ! node->getChildren ( ).empty ( ) ) {
++level;
node = newIter;
--node;
node = & * -- node->getChildren ( ).end ( );
} else {
virtual_node = false;
}
......@@ -256,9 +252,9 @@ public:
const tree * parent = node->getParent ( );
if ( parent != nullptr ) {
if ( node == parent->getChildren ( ).begin ( ) ) {
if ( node == & * parent->getChildren ( ).begin ( ) ) {
--level;
node = typename ext::vector < tree >::const_iterator ( parent );
node = parent;
} else {
--node;
virtual_node = true;
......@@ -370,7 +366,7 @@ public:
*
* \param n the iterator to child list
*/
const_prefix_iterator ( typename ext::vector < tree >::const_iterator n ) : node ( n ) {
const_prefix_iterator ( const tree * n ) : node ( n ) {
}
/**
......@@ -501,7 +497,7 @@ public:
*
* \param n the iterator to child list
*/
const_postfix_iterator ( typename ext::vector < tree >::const_iterator n ) : node ( n ) {
const_postfix_iterator ( const tree * n ) : node ( n ) {
}
/**
......@@ -886,7 +882,7 @@ public:
* \return prefix iterator to the root
*/
const_prefix_iterator prefix_begin ( ) const {
return typename ext::vector < tree >::const_iterator ( this );
return const_prefix_iterator ( this );
}
/**
......@@ -896,7 +892,7 @@ public:
* \return prefix iterator one after the last node in the prefix traversal
*/
const_prefix_iterator prefix_end ( ) const {
const_prefix_iterator res ( typename ext::vector < tree >::const_iterator ( this + 1 ) );
const_prefix_iterator res ( this + 1 );
res.node.isEnd = true;
return res;
......@@ -911,7 +907,7 @@ public:
* \return prefix iterator to the first node in the postfix traversal
*/
const_postfix_iterator postfix_begin ( ) const {
const_postfix_iterator res { typename ext::vector < tree >::const_iterator ( this ) };
const_postfix_iterator res ( this );
while ( ! res.node.getVirtual ( ) ) ++res.node;
......@@ -925,7 +921,7 @@ public:
* \return prefix iterator one after the last node in the postfix traversal
*/
const_postfix_iterator postfix_end ( ) const {
const_postfix_iterator res ( typename ext::vector < tree >::const_iterator ( this + 1 ) );
const_postfix_iterator res ( this + 1 );
res.node.isEnd = true;
return res;
......@@ -940,7 +936,7 @@ public:
* \return prefix iterator to the first node in the traversal
*/
const_structure_iterator structure_begin ( ) const {
return typename ext::vector < tree >::const_iterator ( this );
return const_structure_iterator ( this );
}
/**
......@@ -950,7 +946,7 @@ public:
* \return prefix iterator to one after the last node in the traversal
*/
const_structure_iterator structure_end ( ) const {
const_structure_iterator res ( typename ext::vector < tree >::const_iterator ( this + 1 ) );
const_structure_iterator res ( this + 1 );
res.isEnd = true;
return res;
......
......@@ -204,9 +204,8 @@ std::string to_string ( const ext::tuple < Ts ... > & value ) {
* \result tuple containing values from arguments
*/
template < typename ... _Elements >
constexpr tuple < typename std::__decay_and_strip < _Elements >::__type... > make_tuple ( _Elements && ... __args ) {
typedef tuple < typename std::__decay_and_strip < _Elements >::__type... > __result_type;
return __result_type ( std::forward < _Elements > ( __args ) ... );
constexpr auto make_tuple ( _Elements && ... __args ) {
return tuple < typename ext::strip_reference_wrapper < std::decay_t < _Elements > >::type ... > ( std::forward < _Elements > ( __args ) ... );
}
/**
......
......@@ -975,7 +975,7 @@ inline constexpr void retractInternal ( RandomAccessIterator & i, Distance n, st
template < typename Iterator, typename Distance >
inline constexpr void retract ( Iterator & i, Distance n ) {
typename std::iterator_traits < Iterator >::difference_type d = n;
retractInternal ( i, d, std::__iterator_category ( i ) );
retractInternal ( i, d, typename std::iterator_traits < Iterator >::iterator_category ( ) );
}
/**
......
......@@ -203,6 +203,17 @@ namespace ext {
struct casional < std::false_type, R, Ts ... > : public casional < Ts ... > {
};
// Helper which adds a reference to a type when given a reference_wrapper
template < typename T >
struct strip_reference_wrapper {
typedef T type;
};
template < typename T >
struct strip_reference_wrapper < std::reference_wrapper < T > > {
typedef T & type;
};
} /* namespace ext */
#endif /* __TYPE_TRAITS_HPP_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment