Merge branch 'development' of https://github.com/ETLCPP/etl into development

This commit is contained in:
EXPROGROUP\john.wellbelove 2018-03-02 10:03:11 +00:00
commit b7619d2531
16 changed files with 1130 additions and 653 deletions

View File

@ -1,5 +1,5 @@
name=Embedded Template Library
version=10.20.0
version=10.21.2
author= John Wellbelove <john.wellbelove@etlcpp.com>
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
sentence=A C++ template library tailored for embedded systems.

View File

@ -194,8 +194,8 @@ namespace etl
/// Constructor
//***********************************************************************
Node() :
weight(kNeither),
dir(kNeither)
weight((uint_least8_t) kNeither),
dir((uint_least8_t) kNeither)
{
}
@ -204,8 +204,8 @@ namespace etl
//***********************************************************************
void mark_as_leaf()
{
weight = kNeither;
dir = kNeither;
weight = (uint_least8_t) kNeither;
dir = (uint_least8_t) kNeither;
parent = nullptr;
children[0] = nullptr;
children[1] = nullptr;
@ -245,13 +245,13 @@ namespace etl
Node* weight_node = critical_node->children[critical_node->dir];
while (weight_node)
{
// Keep going until we reach a terminal node (dir == kNeither)
if (kNeither != weight_node->dir)
// Keep going until we reach a terminal node (dir == (uint_least8_t) kNeither)
if ((uint_least8_t) kNeither != weight_node->dir)
{
// Does this insert balance the previous weight factor value?
if (weight_node->weight == 1 - weight_node->dir)
{
weight_node->weight = kNeither;
weight_node->weight = (uint_least8_t) kNeither;
}
else
{
@ -269,14 +269,14 @@ namespace etl
} // while(weight_node)
// Step 2: Update weight for critical_node or rotate tree to balance node
if (kNeither == critical_node->weight)
if ((uint_least8_t) kNeither == critical_node->weight)
{
critical_node->weight = critical_node->dir;
}
// If direction is different than weight, then it will now be balanced
else if (critical_node->dir != critical_node->weight)
{
critical_node->weight = kNeither;
critical_node->weight = (uint_least8_t) kNeither;
}
// Rotate is required to balance the tree at the critical node
else
@ -330,12 +330,12 @@ namespace etl
new_root->dir = 1 - dir;
// Clear weight factor from current position
position->weight = kNeither;
position->weight = (uint_least8_t) kNeither;
// Position's parent becomes new_root
position->parent = new_root;
position = new_root;
// Clear weight factor from new root
position->weight = kNeither;
position->weight = (uint_least8_t) kNeither;
}
//*************************************************************************
@ -358,7 +358,7 @@ namespace etl
// Capture new root (either E or D depending on dir)
Node* new_root = position->children[dir]->children[1 - dir];
// Set weight factor for B or C based on F or G existing and being a different than dir
position->children[dir]->weight = third != kNeither && third != dir ? dir : kNeither;
position->children[dir]->weight = third != (uint_least8_t) kNeither && third != dir ? dir : (uint_least8_t) kNeither;
// Detach new root from its tree (replace with new roots child)
position->children[dir]->children[1 - dir] = new_root->children[dir];
@ -373,7 +373,7 @@ namespace etl
position->children[dir]->parent = new_root;
// Set weight factor for A based on F or G
position->weight = third != kNeither && third == dir ? 1 - dir : kNeither;
position->weight = third != (uint_least8_t) kNeither && third == dir ? 1 - dir : (uint_least8_t) kNeither;
// Move new root's right tree to current roots left tree
position->children[dir] = new_root->children[1 - dir];
@ -391,7 +391,7 @@ namespace etl
position->parent = new_root;
position = new_root;
// Clear weight factor for new current position
position->weight = kNeither;
position->weight = (uint_least8_t) kNeither;
}
//*************************************************************************
@ -402,10 +402,10 @@ namespace etl
if (position)
{
// Is there a tree on the right? then find the minimum of that tree
if (position->children[kRight])
if (position->children[(uint_least8_t) kRight])
{
// Return minimum node found
position = find_limit_node(position->children[kRight], kLeft);
position = find_limit_node(position->children[(uint_least8_t) kRight], kLeft);
}
// Otherwise find the parent of this node
else
@ -418,7 +418,7 @@ namespace etl
// Find parent of current position
parent = position->parent; // find_parent_node(root_node, position);
// Repeat while previous position was on right side of parent tree
} while (parent && parent->children[kRight] == position);
} while (parent && parent->children[(uint_least8_t) kRight] == position);
// Set parent node as the next position
position = parent;
@ -434,10 +434,10 @@ namespace etl
if (position)
{
// Is there a tree on the right? then find the minimum of that tree
if (position->children[kRight])
if (position->children[(uint_least8_t) kRight])
{
// Return minimum node found
position = find_limit_node(position->children[kRight], kLeft);
position = find_limit_node(position->children[(uint_least8_t) kRight], kLeft);
}
// Otherwise find the parent of this node
else
@ -450,7 +450,7 @@ namespace etl
// Find parent of current position
parent = position->parent;
// Repeat while previous position was on right side of parent tree
} while (parent && parent->children[kRight] == position);
} while (parent && parent->children[(uint_least8_t) kRight] == position);
// Set parent node as the next position
position = parent;
@ -472,10 +472,10 @@ namespace etl
else
{
// Is there a tree on the left? then find the maximum of that tree
if (position->children[kLeft])
if (position->children[(uint_least8_t) kLeft])
{
// Return maximum node found
position = find_limit_node(position->children[kLeft], kRight);
position = find_limit_node(position->children[(uint_least8_t) kLeft], kRight);
}
// Otherwise find the parent of this node
else
@ -488,7 +488,7 @@ namespace etl
// Find parent of current position
parent = position->parent;
// Repeat while previous position was on left side of parent tree
} while (parent && parent->children[kLeft] == position);
} while (parent && parent->children[(uint_least8_t) kLeft] == position);
// Set parent node as the next position
position = parent;
@ -510,10 +510,10 @@ namespace etl
else
{
// Is there a tree on the left? then find the maximum of that tree
if (position->children[kLeft])
if (position->children[(uint_least8_t) kLeft])
{
// Return maximum node found
position = find_limit_node(position->children[kLeft], kRight);
position = find_limit_node(position->children[(uint_least8_t) kLeft], kRight);
}
// Otherwise find the parent of this node
else
@ -526,7 +526,7 @@ namespace etl
// Find parent of current position
parent = position->parent;
// Repeat while previous position was on left side of parent tree
} while (parent && parent->children[kLeft] == position);
} while (parent && parent->children[(uint_least8_t) kLeft] == position);
// Set parent node as the next position
position = parent;
@ -589,15 +589,15 @@ namespace etl
// Point swap node to detached node's parent, children and weight
swap->parent = detached->parent;
swap->children[kLeft] = detached->children[kLeft];
swap->children[kRight] = detached->children[kRight];
if (swap->children[kLeft])
swap->children[(uint_least8_t) kLeft] = detached->children[(uint_least8_t) kLeft];
swap->children[(uint_least8_t) kRight] = detached->children[(uint_least8_t) kRight];
if (swap->children[(uint_least8_t) kLeft])
{
swap->children[kLeft]->parent = swap;
swap->children[(uint_least8_t) kLeft]->parent = swap;
}
if (swap->children[kRight])
if (swap->children[(uint_least8_t) kRight])
{
swap->children[kRight]->parent = swap;
swap->children[(uint_least8_t) kRight]->parent = swap;
}
swap->weight = detached->weight;
}
@ -1412,18 +1412,18 @@ namespace etl
if (node_comp(key, data_node))
{
// Keep searching for the node on the left
position = position->children[kLeft];
position = position->children[(uint_least8_t) kLeft];
}
else if (node_comp(data_node, key))
{
// Keep searching for the node on the right
position = position->children[kRight];
position = position->children[(uint_least8_t) kRight];
}
else
{
// We found one, keep looking for more on the left
found = position;
position = position->children[kLeft];
position = position->children[(uint_least8_t) kLeft];
}
}
@ -1445,18 +1445,18 @@ namespace etl
if (node_comp(key, data_node))
{
// Keep searching for the node on the left
position = position->children[kLeft];
position = position->children[(uint_least8_t) kLeft];
}
else if (node_comp(data_node, key))
{
// Keep searching for the node on the right
position = position->children[kRight];
position = position->children[(uint_least8_t) kRight];
}
else
{
// We found one, keep looking for more on the left
found = position;
position = position->children[kLeft];
position = position->children[(uint_least8_t) kLeft];
}
}
@ -1479,9 +1479,9 @@ namespace etl
if (node_comp(key, data_node))
{
lower_node = position;
if (position->children[kLeft])
if (position->children[(uint_least8_t) kLeft])
{
position = position->children[kLeft];
position = position->children[(uint_least8_t) kLeft];
}
else
{
@ -1491,13 +1491,13 @@ namespace etl
}
else if (node_comp(data_node, key))
{
position = position->children[kRight];
position = position->children[(uint_least8_t) kRight];
}
else
{
// Make note of current position, but keep looking to left for more
lower_node = position;
position = position->children[kLeft];
position = position->children[(uint_least8_t) kLeft];
}
}
@ -1521,15 +1521,15 @@ namespace etl
// Compare the key value to the current upper node key value
if (node_comp(data_node, key))
{
position = position->children[kRight];
position = position->children[(uint_least8_t) kRight];
}
else if (node_comp(key, data_node))
{
upper_node = position;
// If a node equal to key hasn't been found go left
if (!found && position->children[kLeft])
if (!found && position->children[(uint_least8_t) kLeft])
{
position = position->children[kLeft];
position = position->children[(uint_least8_t) kLeft];
}
else
{
@ -1566,8 +1566,8 @@ namespace etl
while (found)
{
// Search for critical weight node (all nodes whose weight factor
// is set to kNeither (balanced)
if (kNeither != found->weight)
// is set to (uint_least8_t) kNeither (balanced)
if ((uint_least8_t) kNeither != found->weight)
{
critical_node = found;
}
@ -1579,27 +1579,27 @@ namespace etl
if (node_comp(node, found_data_node))
{
// Update direction taken to insert new node in parent node
found->dir = kLeft;
found->dir = (uint_least8_t) kLeft;
}
// Is the node provided to the right of the current position?
else if (node_comp(found_data_node, node))
{
// Update direction taken to insert new node in parent node
found->dir = kRight;
found->dir = (uint_least8_t) kRight;
}
else
{
// Update direction taken to insert new node in parent (and
// duplicate) node to the right.
found->dir = kRight;
found->dir = (uint_least8_t) kRight;
}
// Is there a child of this parent node?
if (found->children[found->dir])
{
// Will this node be the parent of the next critical node whose
// weight factor is set to kNeither (balanced)?
if (kNeither != found->children[found->dir]->weight)
// weight factor is set to (uint_least8_t) kNeither (balanced)?
if ((uint_least8_t) kNeither != found->children[found->dir]->weight)
{
critical_parent_node = found;
}
@ -1675,7 +1675,7 @@ namespace etl
{
// Which direction does parent use to get to this node?
node->parent->dir =
node->parent->children[kLeft] == node ? kLeft : kRight;
node->parent->children[(uint_least8_t) kLeft] == node ? (uint_least8_t) kLeft : (uint_least8_t) kRight;
// Make this nodes parent the next node
node = node->parent;
@ -1697,20 +1697,20 @@ namespace etl
if (node == found)
{
// Update the direction towards a replacement node at the found node
node->dir = node->children[kLeft] ? kLeft : kRight;
node->dir = node->children[(uint_least8_t) kLeft] ? (uint_least8_t) kLeft : (uint_least8_t) kRight;
// Exit loop and proceed with step 3
break;
}
else
{
// If this nodes weight is kNeither or we are taking the shorter path
// If this nodes weight is (uint_least8_t) kNeither or we are taking the shorter path
// to the next node and our sibling (on longer path) is balanced then
// we need to update the balance node to this node but all our
// ancestors will not require rebalancing
if ((node->weight == kNeither) ||
if ((node->weight == (uint_least8_t) kNeither) ||
(node->weight == (1 - node->dir) &&
node->children[1 - node->dir]->weight == kNeither))
node->children[1 - node->dir]->weight == (uint_least8_t) kNeither))
{
// Update balance node to this node
balance = node;
@ -1737,13 +1737,13 @@ namespace etl
break;
}
// If this nodes weight is kNeither or we are taking the shorter path
// If this nodes weight is (uint_least8_t) kNeither or we are taking the shorter path
// to the next node and our sibling (on longer path) is balanced then
// we need to update the balance node to this node but all our
// ancestors will not require rebalancing
if ((node->weight == kNeither) ||
if ((node->weight == (uint_least8_t) kNeither) ||
(node->weight == (1 - node->dir) &&
node->children[1 - node->dir]->weight == kNeither))
node->children[1 - node->dir]->weight == (uint_least8_t) kNeither))
{
// Update balance node to this node
balance = node;
@ -1759,17 +1759,17 @@ namespace etl
if (node_comp(data_node, replace_data_node))
{
// Update the direction to the replace node
node->dir = kLeft;
node->dir = (uint_least8_t) kLeft;
}
else if (node_comp(replace_data_node, data_node))
{
// Update the direction to the replace node
node->dir = kRight;
node->dir = (uint_least8_t) kRight;
}
else
{
// Update the direction to the replace node
node->dir = node->children[kLeft] ? kLeft : kRight;
node->dir = node->children[(uint_least8_t) kLeft] ? (uint_least8_t) kLeft : (uint_least8_t) kRight;
}
} // while(node)
@ -1783,9 +1783,9 @@ namespace etl
break;
}
// If balance node is balanced already (kNeither) then just imbalance
// If balance node is balanced already ((uint_least8_t) kNeither) then just imbalance
// the node in the opposite direction of the node being removed
if (balance->weight == kNeither)
if (balance->weight == (uint_least8_t) kNeither)
{
balance->weight = 1 - balance->dir;
}
@ -1793,7 +1793,7 @@ namespace etl
// node being removed then the node now becomes balanced
else if (balance->weight == balance->dir)
{
balance->weight = kNeither;
balance->weight = (uint_least8_t) kNeither;
}
// Otherwise a rotation is required at this node
else
@ -1816,7 +1816,7 @@ namespace etl
}
// Already balanced, rebalance and make it heavy in opposite
// direction of the node being removed
else if (weight == kNeither)
else if (weight == (uint_least8_t) kNeither)
{
// Is the root node being rebalanced (no parent)
if (balance->parent == nullptr)

View File

@ -566,7 +566,7 @@ namespace etl
// Capture new root (either E or D depending on dir)
Node* new_root = position->children[dir]->children[1 - dir];
// Set weight factor for B or C based on F or G existing and being a different than dir
position->children[dir]->weight = third != kNeither && third != dir ? dir : kNeither;
position->children[dir]->weight = third != kNeither && third != dir ? dir : uint_least8_t(kNeither);
// Detach new root from its tree (replace with new roots child)
position->children[dir]->children[1 - dir] = new_root->children[dir];

View File

@ -97,6 +97,7 @@ namespace etl
//*****************************************************************************
/// An optional type.
/// If the optional type is not initialised then a type is not constructed.
/// See http://en.cppreference.com/w/cpp/utility/optional
///\tparam The type to store.
///\ingroup utilities
//*****************************************************************************
@ -329,7 +330,7 @@ void swap(etl::optional<T>& lhs, etl::optional<T>& rhs)
}
//***************************************************************************
/// Equality operator.
/// Equality operator. cppreference 1
//***************************************************************************
template <typename T>
bool operator ==(const etl::optional<T>& lhs, const etl::optional<T>& rhs)
@ -349,7 +350,16 @@ bool operator ==(const etl::optional<T>& lhs, const etl::optional<T>& rhs)
}
//***************************************************************************
/// Less than operator.
/// Equality operator. cppreference 2
//***************************************************************************
template <typename T>
bool operator !=(const etl::optional<T>& lhs, const etl::optional<T>& rhs)
{
return !(lhs == rhs);
}
//***************************************************************************
/// Less than operator. cppreference 3
//***************************************************************************
template <typename T>
bool operator <(const etl::optional<T>& lhs, const etl::optional<T>& rhs)
@ -369,7 +379,67 @@ bool operator <(const etl::optional<T>& lhs, const etl::optional<T>& rhs)
}
//***************************************************************************
/// Equality operator.
/// Less than equal operator. cppreference 4
//***************************************************************************
template <typename T>
bool operator <=(const etl::optional<T>& lhs, const etl::optional<T>& rhs)
{
if (!bool(lhs))
{
return true;
}
else if (!bool(rhs))
{
return false;
}
else
{
return lhs.value() <= rhs.value();
}
}
//***************************************************************************
/// greater than operator. cppreference 5
//***************************************************************************
template <typename T>
bool operator >(const etl::optional<T>& lhs, const etl::optional<T>& rhs)
{
if (!bool(lhs))
{
return false;
}
else if (!bool(rhs))
{
return true;
}
else
{
return lhs.value() > rhs.value();
}
}
//***************************************************************************
/// greater than equal operator. cppreference 6
//***************************************************************************
template <typename T>
bool operator >=(const etl::optional<T>& lhs, const etl::optional<T>& rhs)
{
if (!bool(rhs))
{
return true;
}
else if (!bool(lhs))
{
return false;
}
else
{
return lhs.value() >= rhs.value();
}
}
//***************************************************************************
/// Equality operator. cppreference 7
//***************************************************************************
template <typename T>
bool operator ==(const etl::optional<T>& lhs, etl::nullopt_t)
@ -378,25 +448,43 @@ bool operator ==(const etl::optional<T>& lhs, etl::nullopt_t)
}
//***************************************************************************
/// Equality operator.
/// Equality operator. cppreference 8
//***************************************************************************
template <typename T>
bool operator ==(etl::nullopt_t, const etl::optional<T>& rhs)
{
return !bool(rhs);
}
//***************************************************************************
/// Inequality operator. cppreference 9
//***************************************************************************
template <typename T>
bool operator !=(const etl::optional<T>& lhs, etl::nullopt_t)
{
return !(lhs == etl::nullopt);
}
//***************************************************************************
/// Inequality operator. cppreference 10
//***************************************************************************
template <typename T>
bool operator !=(etl::nullopt_t , const etl::optional<T>& rhs)
{
return !(etl::nullopt == rhs);
}
//***************************************************************************
/// Less than operator. cppreference 11
//***************************************************************************
template <typename T>
bool operator <(const etl::optional<T>&, etl::nullopt_t)
{
return false;
}
//***************************************************************************
/// Less than operator.
//***************************************************************************
template <typename T>
bool operator <(const etl::optional<T>& lhs, etl::nullopt_t)
{
return !bool(lhs);
}
//***************************************************************************
/// Less than operator.
/// Less than operator. cppreference 12
//***************************************************************************
template <typename T>
bool operator <(etl::nullopt_t, const etl::optional<T>& rhs)
@ -405,32 +493,167 @@ bool operator <(etl::nullopt_t, const etl::optional<T>& rhs)
}
//***************************************************************************
/// Equality operator.
//**************************************************************************
/// Less than equal operator. cppreference 13
//***************************************************************************
template <typename T>
bool operator ==(const etl::optional<T>& lhs, const T& rhs)
bool operator <=(const etl::optional<T>& lhs, etl::nullopt_t)
{
return !bool(lhs);
}
//***************************************************************************
/// Less than equal operator. cppreference 14
//***************************************************************************
template <typename T>
bool operator <=(etl::nullopt_t, const etl::optional<T>&)
{
return true;
}
//***************************************************************************
/// Greater than operator. cppreference 15
//***************************************************************************
template <typename T>
bool operator >(const etl::optional<T>& lhs, etl::nullopt_t)
{
return bool(lhs);
}
//***************************************************************************
/// Greater than operator. cppreference 16
//***************************************************************************
template <typename T>
bool operator >(etl::nullopt_t, const etl::optional<T>&)
{
return false;
}
//***************************************************************************
/// Greater than equal operator. cppreference 17
//***************************************************************************
template <typename T>
bool operator >=(const etl::optional<T>&, etl::nullopt_t)
{
return true;
}
//***************************************************************************
/// Greater than equal operator. cppreference 18
//***************************************************************************
template <typename T>
bool operator >=(etl::nullopt_t, const etl::optional<T>& rhs)
{
return !bool(rhs);
}
//***************************************************************************
/// Equality operator. cppreference 19
//**************************************************************************
template <typename T, typename U>
bool operator ==(const etl::optional<T>& lhs, const U& rhs)
{
return bool(lhs) ? lhs.value() == rhs : false;
}
//***************************************************************************
/// Equality operator.
/// Inequality operator. cppreference 21
//**************************************************************************
template <typename T>
bool operator ==(const T& value, const etl::optional<T>& rhs)
template <typename T, typename U>
bool operator !=(const etl::optional<T>& lhs, const U& rhs)
{
return bool(rhs) ? rhs.value() == value : false;
return !(lhs == rhs);
}
//***************************************************************************
/// Less than operator.
/// Equality operator. cppreference 20
//**************************************************************************
template <typename T, typename U>
bool operator ==(const U& lhs, const etl::optional<T>& rhs)
{
return bool(rhs) ? rhs.value() == lhs : false;
}
//***************************************************************************
template <typename T>
bool operator <(const etl::optional<T>& lhs, const T& rhs)
/// Inequality operator. cppreference 22
//**************************************************************************
template <typename T, typename U>
bool operator !=(const U& lhs, const etl::optional<T>& rhs)
{
return !(lhs == rhs);
}
//***************************************************************************
/// Less than operator. cppreference 23
//***************************************************************************
template <typename T, typename U>
bool operator <(const etl::optional<T>& lhs, const U& rhs)
{
return bool(lhs) ? lhs.value() < rhs : true;
}
//***************************************************************************
/// Less than operator. cppreference 24
//***************************************************************************
template <typename T, typename U>
bool operator <(const U& lhs, const etl::optional<T>& rhs)
{
return bool(rhs) ? lhs < rhs.value() : false;
}
//***************************************************************************
/// Less than equal operator. cppreference 25
//***************************************************************************
template <typename T, typename U>
bool operator <=(const etl::optional<T>& lhs, const U& rhs)
{
return bool(lhs) ? lhs.value() <= rhs : true;
}
//***************************************************************************
/// Less than equal operator. cppreference 26
//***************************************************************************
template <typename T, typename U>
bool operator <=(const U& lhs, const etl::optional<T>& rhs)
{
return bool(rhs) ? lhs <= rhs.value() : false;
}
//***************************************************************************
/// Greater than operator. cppreference 27
//***************************************************************************
template <typename T, typename U>
bool operator >(const etl::optional<T>& lhs, const U& rhs)
{
return bool(lhs) ? lhs.value() > rhs : false;
}
//***************************************************************************
/// Greater than operator. cppreference 28
//***************************************************************************
template <typename T, typename U>
bool operator >(const U& lhs, const etl::optional<T>& rhs)
{
return bool(rhs) ? lhs > rhs.value() : true;
}
//***************************************************************************
/// Greater than equal operator. cppreference 29
//***************************************************************************
template <typename T, typename U>
bool operator >=(const etl::optional<T>& lhs, const U& rhs)
{
return bool(lhs) ? lhs.value() >= rhs : false;
}
//***************************************************************************
/// Greater than equal operator. cppreference 30
//***************************************************************************
template <typename T, typename U>
bool operator >=(const U& lhs, const etl::optional<T>& rhs)
{
return bool(rhs) ? lhs >= rhs.value() : true;
}
//***************************************************************************
/// Make an optional.
//***************************************************************************

View File

@ -101,7 +101,7 @@ namespace etl
template <int ID>
struct type_from_id
{
typedef
typedef
typename etl::conditional<ID == T1::ID, typename T1::type,
typename etl::conditional<ID == T2::ID, typename T2::type,
typename etl::conditional<ID == T3::ID, typename T3::type,
@ -138,22 +138,22 @@ namespace etl
enum
{
value =
(unsigned int) etl::is_same<T, typename T1::type>::value ? T1::ID :
(unsigned int) etl::is_same<T, typename T2::type>::value ? T2::ID :
(unsigned int) etl::is_same<T, typename T3::type>::value ? T3::ID :
(unsigned int) etl::is_same<T, typename T4::type>::value ? T4::ID :
(unsigned int) etl::is_same<T, typename T5::type>::value ? T5::ID :
(unsigned int) etl::is_same<T, typename T6::type>::value ? T6::ID :
(unsigned int) etl::is_same<T, typename T7::type>::value ? T7::ID :
(unsigned int) etl::is_same<T, typename T8::type>::value ? T8::ID :
(unsigned int) etl::is_same<T, typename T9::type>::value ? T9::ID :
(unsigned int) etl::is_same<T, typename T10::type>::value ? T10::ID :
(unsigned int) etl::is_same<T, typename T11::type>::value ? T11::ID :
(unsigned int) etl::is_same<T, typename T12::type>::value ? T12::ID :
(unsigned int) etl::is_same<T, typename T13::type>::value ? T13::ID :
(unsigned int) etl::is_same<T, typename T14::type>::value ? T14::ID :
(unsigned int) etl::is_same<T, typename T15::type>::value ? T15::ID :
(unsigned int) etl::is_same<T, typename T16::type>::value ? T16::ID :
(unsigned int) etl::is_same<T, typename T1::type>::value ? (unsigned int)T1::ID :
(unsigned int) etl::is_same<T, typename T2::type>::value ? (unsigned int)T2::ID :
(unsigned int) etl::is_same<T, typename T3::type>::value ? (unsigned int)T3::ID :
(unsigned int) etl::is_same<T, typename T4::type>::value ? (unsigned int)T4::ID :
(unsigned int) etl::is_same<T, typename T5::type>::value ? (unsigned int)T5::ID :
(unsigned int) etl::is_same<T, typename T6::type>::value ? (unsigned int)T6::ID :
(unsigned int) etl::is_same<T, typename T7::type>::value ? (unsigned int)T7::ID :
(unsigned int) etl::is_same<T, typename T8::type>::value ? (unsigned int)T8::ID :
(unsigned int) etl::is_same<T, typename T9::type>::value ? (unsigned int)T9::ID :
(unsigned int) etl::is_same<T, typename T10::type>::value ? (unsigned int)T10::ID :
(unsigned int) etl::is_same<T, typename T11::type>::value ? (unsigned int)T11::ID :
(unsigned int) etl::is_same<T, typename T12::type>::value ? (unsigned int)T12::ID :
(unsigned int) etl::is_same<T, typename T13::type>::value ? (unsigned int)T13::ID :
(unsigned int) etl::is_same<T, typename T14::type>::value ? (unsigned int)T14::ID :
(unsigned int) etl::is_same<T, typename T15::type>::value ? (unsigned int)T15::ID :
(unsigned int) etl::is_same<T, typename T16::type>::value ? (unsigned int)T16::ID :
(unsigned int) UNKNOWN
};
@ -202,7 +202,7 @@ namespace etl
template <typename T>
struct type_from_type
{
typedef
typedef
typename etl::conditional<etl::is_same<T, typename T1::type1>::value, typename T1::type2,
typename etl::conditional<etl::is_same<T, typename T2::type1>::value, typename T2::type2,
typename etl::conditional<etl::is_same<T, typename T3::type1>::value, typename T3::type2,

View File

@ -645,12 +645,20 @@ namespace etl
TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId)
{
return reinterpret_cast<U1&>(*p_data);
switch (typeId)
{
case 0: return reinterpret_cast<U1&>(*p_data);
default: return reinterpret_cast<TBase&>(*reinterpret_cast<TBase*>(0));
}
}
const TBase& operator()(uint_least8_t* p_data, uint_least8_t typeId) const
{
return reinterpret_cast<const U1&>(*p_data);
switch (typeId)
{
case 0: return reinterpret_cast<const U1&>(*p_data);
default: return reinterpret_cast<const TBase&>(*reinterpret_cast<const TBase*>(0));
}
}
};

46
src/version.h Normal file
View File

@ -0,0 +1,46 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2018 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_VERSION__
#define __ETL_VERSION__
#include <stdint.h>
///\defgroup version version
/// Definitions of the ETL version
///\ingroup utilities
#define ETL_VERSION "10.21.2"
#define ETL_VERSION_MAJOR 10
#define ETL_VERSION_MINOR 21
#define ETL_VERSION_PATCH 2
#endif

View File

@ -1,3 +1,16 @@
===============================================================================
10.21.2
Added version.h
===============================================================================
10.21.1
Removal of GCC warnings from variant.h.
===============================================================================
10.21.0
Completion of operator set for etl::optional
Removal of more GCC warnings when using -Wextra.
===============================================================================
10.20.0
Rewrite of debounce code to factor out commonality.

View File

@ -208,6 +208,7 @@
<Unit filename="../../src/variant.h" />
<Unit filename="../../src/variant_pool.h" />
<Unit filename="../../src/vector.h" />
<Unit filename="../../src/version.h" />
<Unit filename="../../src/visitor.h" />
<Unit filename="../../src/wstring.h" />
<Unit filename="../../unittest-cpp/UnitTest++/AssertException.cpp" />

File diff suppressed because it is too large Load Diff

View File

@ -63,6 +63,16 @@ public:
return value > other.value;
}
bool operator <= (const TestDataDC& other) const
{
return !(value > other.value);
}
bool operator >= (const TestDataDC& other) const
{
return !(value < other.value);
}
T value;
int index;
};
@ -109,6 +119,16 @@ public:
return value > other.value;
}
bool operator <= (const TestDataNDC& other) const
{
return !(value > other.value);
}
bool operator >= (const TestDataNDC& other) const
{
return !(value < other.value);
}
T value;
int index;
};

View File

@ -7,6 +7,12 @@
// compile and run any of them on any platform, but your performance with the
// non-native version will be less than optimal.
#include "platform.h"
#ifdef ETL_COMPILER_GCC
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#endif
#include "murmurhash3.h"
//-----------------------------------------------------------------------------

View File

@ -114,24 +114,71 @@ namespace
etl::optional<Data> data2;
CHECK(data1 == data2);
CHECK(data2 == data1);
data1 = Data("Data1");
CHECK(!(data1 == data2));
CHECK(!(data2 == data1));
data1 = etl::nullopt;
data2 = Data("Data2");
CHECK(!(data1 == data2));
CHECK(!(data2 == data1));
data1 = Data("Data1");
data2 = Data("Data1");
CHECK(data1 == data2);
CHECK(data2 == data1);
data1 = Data("Data1");
data2 = Data("Data2");
CHECK(!(data1 == data2));
CHECK(!(data2 == data1));
CHECK(!(etl::nullopt == data2));
CHECK(!(data1 == etl::nullopt));
CHECK(data1 == Data("Data1"));
CHECK(!(data1 == Data("Data2")));
CHECK(Data("Data1") == data1);
CHECK(!(Data("Data2") == data1));
}
//*************************************************************************
TEST(test_inequality)
{
etl::optional<Data> data1;
etl::optional<Data> data2;
CHECK(!(data1 != data2));
CHECK(!(data2 != data1));
data1 = Data("Data1");
CHECK(data1 != data2);
CHECK(data2 != data1);
data1 = etl::nullopt;
data2 = Data("Data2");
CHECK(data1 != data2);
CHECK(data2 != data1);
data1 = Data("Data1");
data2 = Data("Data1");
CHECK(!(data1 != data2));
CHECK(!(data2 != data1));
data1 = Data("Data1");
data2 = Data("Data2");
CHECK(data1 != data2);
CHECK(data2 != data1);
CHECK(etl::nullopt != data2);
CHECK(data1 != etl::nullopt);
CHECK(!(data1 != Data("Data1")));
CHECK(data1 != Data("Data2"));
CHECK(!(Data("Data1") != data1));
CHECK(Data("Data2") != data1);
}
//*************************************************************************
@ -140,22 +187,130 @@ namespace
etl::optional<Data> data1;
etl::optional<Data> data2;
CHECK(!(data2 < data1));
CHECK(!(data1 < data2));
data1 = Data("Data1");
CHECK(!(data1 < data2));
CHECK(data2 < data1);
data1 = etl::nullopt;
data2 = Data("Data2");
CHECK(data1 < data2);
CHECK(!(data2 < data2));
data1 = Data("Data1");
data2 = Data("Data2");
CHECK(data1 < data2);
CHECK(!(data2 < data1));
CHECK(etl::nullopt < data2);
CHECK(!(data1 < etl::nullopt));
CHECK(data1 < Data("Data2"));
CHECK(!(data1 < Data("Data1")));
CHECK(!(Data("Data2") < data1));
CHECK(Data("Data1") < data2);
}
//*************************************************************************
TEST(test_less_than_equal)
{
etl::optional<Data> data1;
etl::optional<Data> data2;
CHECK(data1 <= data2);
CHECK(data2 <= data1);
data1 = Data("Data1");
CHECK(!(data1 <= data2));
CHECK(data2 <= data1);
data1 = etl::nullopt;
data2 = Data("Data2");
CHECK(data1 <= data2);
CHECK(!(data2 <= data1));
data1 = Data("Data1");
data2 = Data("Data2");
CHECK(data1 <= data2);
CHECK(!(data2 <= data1));
CHECK(etl::nullopt <= data2);
CHECK(!(data1 <= etl::nullopt));
CHECK(data1 <= Data("Data2"));
CHECK(!(data2 <= Data("Data1")));
CHECK(data1 <= Data("Data1"));
CHECK(!(Data("Data2") <= data1));
CHECK(Data("Data1") <= data2);
CHECK(Data("Data1") <= data1);
}
//*************************************************************************
TEST(test_greater_than)
{
etl::optional<Data> data1;
etl::optional<Data> data2;
CHECK(!(data1 > data2));
CHECK(!(data2 > data1));
data1 = Data("Data1");
CHECK(data1 > data2);
CHECK(!(data2 > data1));
data1 = etl::nullopt;
data2 = Data("Data2");
CHECK(!(data1 > data2));
CHECK(data2 > data1);
data1 = Data("Data1");
data2 = Data("Data2");
CHECK(data2 > data1);
CHECK(!(data1 > data2));
CHECK(!(etl::nullopt > data2));
CHECK(data1 > etl::nullopt);
CHECK(!(data1 > Data("Data2")));
CHECK(data2 > Data("Data1"));
CHECK(Data("Data2") > data1);
CHECK(!(Data("Data1") > data2));
}
//*************************************************************************
TEST(test_greater_than_equal)
{
etl::optional<Data> data1;
etl::optional<Data> data2;
CHECK(data1 >= data2);
CHECK(data2 >= data1);
data1 = Data("Data1");
CHECK(data1 >= data2);
CHECK(!(data2 >= data1));
data1 = etl::nullopt;
data2 = Data("Data2");
CHECK(!(data1 >= data2));
CHECK(data2 >= data1);
data1 = Data("Data1");
data2 = Data("Data2");
CHECK(!(data1 >= data2));
CHECK(data2 >= data1);
CHECK(!(etl::nullopt >= data2));
CHECK(data1 >= etl::nullopt);
CHECK(!(data1 >= Data("Data2")));
CHECK(data2 >= Data("Data1"));
CHECK(data1 >= Data("Data1"));
CHECK(Data("Data2") >= data1);
CHECK(!(Data("Data1") >= data2));
CHECK(Data("Data1") >= data1);
}
//*************************************************************************

View File

@ -132,7 +132,7 @@ namespace
return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c) && (lhs.d == rhs.d);
}
std::ostream& operator <<(std::ostream& os, const D0& d)
std::ostream& operator <<(std::ostream& os, const D0&)
{
return os;
}

View File

@ -172,6 +172,7 @@
<ClInclude Include="..\..\src\type_traits_generator.h" />
<ClInclude Include="..\..\src\variant_pool.h" />
<ClInclude Include="..\..\src\variant_pool_generator.h" />
<ClInclude Include="..\..\src\version.h" />
<ClInclude Include="..\..\unittest-cpp\UnitTest++\AssertException.h" />
<ClInclude Include="..\..\unittest-cpp\UnitTest++\CheckMacros.h" />
<ClInclude Include="..\..\unittest-cpp\UnitTest++\Checks.h" />

View File

@ -576,6 +576,9 @@
<ClInclude Include="..\..\src\variant_pool_generator.h">
<Filter>ETL\Containers\Generators</Filter>
</ClInclude>
<ClInclude Include="..\..\src\version.h">
<Filter>ETL\Utilities</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\main.cpp">