Skip to content

Commit

Permalink
Merge branch 'pull-request/ETLCPP#861-Implement-Constexpr-Strong-Type…
Browse files Browse the repository at this point in the history
…def' into feature/838-strong-typedef-constexpr
  • Loading branch information
drewr95 authored Mar 13, 2024
2 parents 276c934 + 48c496c commit a455206
Show file tree
Hide file tree
Showing 162 changed files with 15,431 additions and 7,290 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -386,3 +386,4 @@ test/vs2022/Debug MSVC C++20 - No virtual messages
examples/MutexMessageRouter/.vs
support/time remaining test.xlsx
test/vs2022/Debug MSVC C++20 - Force C++03
test/vs2022/Release MSVC C++20 - No STL - Optimised -O2 - Sanitiser
2 changes: 1 addition & 1 deletion cmake/GetGitRevisionDescription.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
# function returns an empty string via _git_dir_var.
#
# Example: Given a path C:/bla/foo/bar and assuming C:/bla/.git exists and
# neither foo nor bar contain a file/directory .git. This wil return
# neither foo nor bar contain a file/directory .git. This will return
# C:/bla/.git
#
function(_git_find_closest_git_dir _start_dir _git_dir_var)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Uart uart1(0, USART1_IRQ_HANDLER);
Uart uart2(1, USART2_IRQ_HANDLER);

// Declare a global callback for the timer.
// Uses the most efficient callback type for a class, as everthing is known at compile time.
// Uses the most efficient callback type for a class, as everything is known at compile time.
etl::delegate<void(size_t)> timer_member_callback = etl::delegate<void(size_t)>::create<Timer, timer, &Timer::InterruptHandler>();

// Declare the callbacks for the free functions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Uart uart1(0, USART1_IRQ_HANDLER);
Uart uart2(1, USART2_IRQ_HANDLER);

// Declare a global callback for the timer.
// Uses the most efficient callback type for a class, as everthing is known at compile time.
// Uses the most efficient callback type for a class, as everything is known at compile time.
etl::function_imp<Timer, size_t, timer, &Timer::InterruptHandler> timer_member_callback;

// Declare the callbacks for the free functions.
Expand Down
20 changes: 14 additions & 6 deletions include/etl/algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@ namespace etl
return first2;
}

//***************************************************************************
// generate
template <typename TIterator, typename TFunction>
ETL_CONSTEXPR14
void generate(TIterator db, TIterator de, TFunction funct)
{
while (db != de)
{
*db++ = funct();
}
}

//***************************************************************************
// copy
#if ETL_USING_STL && ETL_USING_CPP20
Expand Down Expand Up @@ -2009,9 +2021,7 @@ namespace etl
template <typename TIterator, typename T>
ETL_CONSTEXPR14
TIterator remove(TIterator first, TIterator last, const T& value)
{
first = etl::find(first, last, value);

{
if (first != last)
{
TIterator itr = first;
Expand Down Expand Up @@ -2039,8 +2049,6 @@ namespace etl
ETL_CONSTEXPR14
TIterator remove_if(TIterator first, TIterator last, TUnaryPredicate predicate)
{
first = etl::find_if(first, last, predicate);

if (first != last)
{
TIterator itr = first;
Expand Down Expand Up @@ -2177,7 +2185,7 @@ namespace etl
//***************************************************************************
/// copy_if
/// A safer form of copy_if where it terminates when the first end iterator is reached.
/// There is currently no STL equivelent.
/// There is currently no STL equivalent.
///\ingroup algorithm
//***************************************************************************
template <typename TInputIterator,
Expand Down
30 changes: 17 additions & 13 deletions include/etl/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ namespace etl

static ETL_CONSTANT size_t SIZE = SIZE_;

typedef T value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T& reference;
typedef const T& const_reference;
typedef T* pointer;
typedef const T* const_pointer;
typedef T* iterator;
typedef const T* const_iterator;
typedef T value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T& reference;
typedef const T& const_reference;
typedef T* pointer;
typedef const T* const_pointer;
typedef T* iterator;
typedef const T* const_iterator;
typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;

Expand Down Expand Up @@ -386,27 +386,31 @@ namespace etl
/// If the range is smaller than the array then the unused array elements are left unmodified.
///\param first The iterator to the first item in the range.
///\param last The iterator to one past the final item in the range.
///\return An iterator to the first unassigned array element, or end().
//*************************************************************************
template <typename TIterator>
void assign(TIterator first, const TIterator last)
iterator assign(TIterator first, const TIterator last)
{
etl::copy_s(first, last, begin(), end());
return etl::copy_s(first, last, begin(), end());
}

//*************************************************************************
/// Fills the array from the range.
/// If the range is smaller than the array then the unused array elements are initialised with the supplied value.
///\param first The iterator to the first item in the range.
///\param last The iterator to one past the final item in the range.
///\return An iterator to the first array element set to 'value', or end().
//*************************************************************************
template <typename TIterator>
void assign(TIterator first, const TIterator last, parameter_t value)
iterator assign(TIterator first, const TIterator last, parameter_t value)
{
// Copy from the range.
iterator p = etl::copy(first, last, begin());
iterator p = etl::copy_s(first, last, begin(), end());

// Initialise any that are left.
etl::fill(p, end(), value);

return p;
}

//*************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion include/etl/atomic/atomic_gcc_sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ namespace etl

T operator --(int) volatile
{
return __atomic_fetch_sub(&value, 1), etl::memory_order_seq_cst;
return __atomic_fetch_sub(&value, 1, etl::memory_order_seq_cst);
}

// Add
Expand Down
4 changes: 2 additions & 2 deletions include/etl/basic_format_spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ namespace etl
static ETL_CONSTANT private_basic_format_spec::base_spec hex(16U);

//*********************************
static ETL_CONSTANT private_basic_format_spec::left_spec left;
static ETL_CONSTANT private_basic_format_spec::left_spec left = private_basic_format_spec::left_spec();

//*********************************
static ETL_CONSTANT private_basic_format_spec::right_spec right;
static ETL_CONSTANT private_basic_format_spec::right_spec right = private_basic_format_spec::right_spec();

//*********************************
static ETL_CONSTANT private_basic_format_spec::boolalpha_spec boolalpha(true);
Expand Down
2 changes: 1 addition & 1 deletion include/etl/basic_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ namespace etl
/// Erases a sequence.
///\param position Position to start from.
///\param length Number of characters.
///\return A refernce to this string.
///\return A reference to this string.
//*********************************************************************
etl::ibasic_string<T>& erase(size_type position, size_type length_ = npos)
{
Expand Down
68 changes: 34 additions & 34 deletions include/etl/basic_string_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,28 @@ namespace etl
}

//*************************************************************************
/// Construct from text and format spec.
/// Construct from text and format fmt.
//*************************************************************************
basic_string_stream(TIString& text_, const TFormat& spec_)
: text(text_)
, spec(spec_)
, format(spec_)
{
}

//*************************************************************************
/// Set the format spec.
/// Set the format fmt.
//*************************************************************************
void set_format(const TFormat& spec_)
{
spec = spec_;
format = spec_;
}

//*************************************************************************
/// Get a const reference to the format spec.
/// Get a const reference to the format fmt.
//*************************************************************************
const TFormat& get_format() const
{
return spec;
return format;
}

//*************************************************************************
Expand Down Expand Up @@ -121,91 +121,91 @@ namespace etl
//*********************************
/// TFormat
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, const TFormat& spec)
friend basic_string_stream& operator <<(basic_string_stream& ss, const TFormat& fmt)
{
ss.spec = spec;
ss.format = fmt;
return ss;
}

//*********************************
/// etl::base_spec from etl::setbase, etl::bin, etl::oct, etl::dec & etl::hex stream manipulators
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::base_spec spec)
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::base_spec fmt)
{
ss.spec.base(spec.base);
ss.format.base(fmt.base);
return ss;
}

//*********************************
/// etl::width_spec from etl::setw stream manipulator
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::width_spec spec)
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::width_spec fmt)
{
ss.spec.width(spec.width);
ss.format.width(fmt.width);
return ss;
}

//*********************************
/// etl::fill_spec from etl::setfill stream manipulator
//*********************************
template <typename TChar>
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::fill_spec<TChar> spec)
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::fill_spec<TChar> fmt)
{
ss.spec.fill(spec.fill);
ss.format.fill(fmt.fill);
return ss;
}

//*********************************
/// etl::precision_spec from etl::setprecision stream manipulator
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::precision_spec spec)
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::precision_spec fmt)
{
ss.spec.precision(spec.precision);
ss.format.precision(fmt.precision);
return ss;
}

//*********************************
/// etl::boolalpha_spec from etl::boolalpha & etl::noboolalpha stream manipulators
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::boolalpha_spec spec)
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::boolalpha_spec fmt)
{
ss.spec.boolalpha(spec.boolalpha);
ss.format.boolalpha(fmt.boolalpha);
return ss;
}

//*********************************
/// etl::uppercase_spec from etl::uppercase & etl::nouppercase stream manipulators
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::uppercase_spec spec)
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::uppercase_spec fmt)
{
ss.spec.upper_case(spec.upper_case);
ss.format.upper_case(fmt.upper_case);
return ss;
}

//*********************************
/// etl::showbase_spec from etl::showbase & etl::noshowbase stream manipulators
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::showbase_spec spec)
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::showbase_spec fmt)
{
ss.spec.show_base(spec.show_base);
ss.format.show_base(fmt.show_base);
return ss;
}

//*********************************
/// etl::left_spec from etl::left stream manipulator
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::left_spec /*spec*/)
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::left_spec /*fmt*/)
{
ss.spec.left();
ss.format.left();
return ss;
}

//*********************************
/// etl::right_spec from etl::left stream manipulator
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::right_spec /*spec*/)
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::right_spec /*fmt*/)
{
ss.spec.right();
ss.format.right();
return ss;
}

Expand All @@ -214,7 +214,7 @@ namespace etl
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, TStringView view)
{
etl::to_string(view, ss.text, ss.spec, true);
etl::to_string(view, ss.text, ss.format, true);
return ss;
}

Expand All @@ -241,19 +241,19 @@ namespace etl
//*********************************
/// From a string interface
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, const TIString& text)
friend basic_string_stream& operator <<(basic_string_stream& ss, const TIString& t)
{
etl::to_string(text, ss.text, ss.spec, true);
etl::to_string(t, ss.text, ss.format, true);
return ss;
}

//*********************************
/// From a string
//*********************************
template <template <size_t> class TString, size_t SIZE>
friend basic_string_stream& operator <<(basic_string_stream& ss, const TString<SIZE>& text)
friend basic_string_stream& operator <<(basic_string_stream& ss, const TString<SIZE>& t)
{
const TIString& itext = text;
const TIString& itext = t;
etl::to_string(itext, ss.str(), ss.get_format(), true);
return ss;
}
Expand All @@ -264,14 +264,14 @@ namespace etl
template <typename T>
friend basic_string_stream& operator <<(basic_string_stream& ss, const T& value)
{
etl::to_string(value, ss.text, ss.spec, true);
etl::to_string(value, ss.text, ss.format, true);
return ss;
}

private:

TIString& text;
TFormat spec;
TIString& text;
TFormat format;

basic_string_stream(const basic_string_stream&) ETL_DELETE;
basic_string_stream& operator =(const basic_string_stream&) ETL_DELETE;
Expand Down
Loading

0 comments on commit a455206

Please sign in to comment.