Add container_type type definition to etl::queue to better match std::queue (#378)

* Add container_type type definition to better match std::queue

* Add container_type typedef to priority_queue and stack classes to maximize compatibility with the std library
This commit is contained in:
Daníel Grétarsson 2021-05-20 08:14:31 +00:00 committed by GitHub
parent f131356dc2
commit 9c2b5c3d75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -418,6 +418,7 @@ namespace etl
public:
typedef typename TContainer::size_type size_type;
typedef TContainer container_type;
static ETL_CONSTANT size_type MAX_SIZE = size_type(SIZE);

View File

@ -584,7 +584,8 @@ namespace etl
public:
typedef typename base_t::size_type size_type;
typedef typename base_t::size_type size_type;
typedef typename etl::aligned_storage<sizeof(T), etl::alignment_of<T>::value>::type container_type;
ETL_STATIC_ASSERT((SIZE <= etl::integral_limits<size_type>::max), "Size too large for memory model");
@ -657,7 +658,7 @@ namespace etl
private:
/// The uninitialised buffer of T used in the queue.
typename etl::aligned_storage<sizeof(T), etl::alignment_of<T>::value>::type buffer[SIZE];
container_type buffer[SIZE];
};
}

View File

@ -528,6 +528,7 @@ namespace etl
class stack : public etl::istack<T>
{
public:
typedef typename etl::aligned_storage<sizeof(T), etl::alignment_of<T>::value>::type container_type;
static ETL_CONSTANT size_t MAX_SIZE = SIZE;
@ -598,7 +599,7 @@ namespace etl
private:
/// The unintitialised buffer of T used in the stack.
typename etl::aligned_storage<sizeof(T), etl::alignment_of<T>::value>::type buffer[SIZE];
container_type buffer[SIZE];
};
}