Skip to content

Commit

Permalink
Merge branch 'pull-request/#905-Add-support-for-type_identity' into d…
Browse files Browse the repository at this point in the history
…evelopment
  • Loading branch information
John Wellbelove committed Jun 11, 2024
2 parents a8f5935 + 76f2cfb commit e159a6b
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/etl/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace etl

//***************************************************************************
/// Gets the line for the exception.
/// \return const char* to the line.
/// \return int as line number.
//***************************************************************************
ETL_CONSTEXPR
numeric_type line_number() const
Expand Down
11 changes: 11 additions & 0 deletions include/etl/generators/type_traits_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -2295,6 +2295,17 @@ typedef integral_constant<bool, true> true_type;
template <typename T>
using signed_type_t = typename signed_type<T>::type;
#endif

//*********************************************
// type_identity

template <typename T>
struct type_identity { typedef T type; };

#if ETL_USING_CPP11
template <typename T>
using type_identity_t = typename type_identity<T>::type;
#endif
}

// Helper macros
Expand Down
11 changes: 11 additions & 0 deletions include/etl/type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -2288,6 +2288,17 @@ typedef integral_constant<bool, true> true_type;
template <typename T>
using signed_type_t = typename signed_type<T>::type;
#endif

//*********************************************
// type_identity

template <typename T>
struct type_identity { typedef T type; };

#if ETL_USING_CPP11
template <typename T>
using type_identity_t = typename type_identity<T>::type;
#endif
}

// Helper macros
Expand Down
2 changes: 1 addition & 1 deletion include/etl/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ SOFTWARE.

#define ETL_VERSION_MAJOR 20
#define ETL_VERSION_MINOR 38
#define ETL_VERSION_PATCH 16
#define ETL_VERSION_PATCH 17

#define ETL_VERSION ETL_STRING(ETL_VERSION_MAJOR) "." ETL_STRING(ETL_VERSION_MINOR) "." ETL_STRING(ETL_VERSION_PATCH)
#define ETL_VERSION_W ETL_WIDE_STRING(ETL_VERSION_MAJOR) L"." ETL_WIDE_STRING(ETL_VERSION_MINOR) L"." ETL_WIDE_STRING(ETL_VERSION_PATCH)
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Embedded Template Library",
"version": "20.38.16",
"version": "20.38.17",
"authors": {
"name": "John Wellbelove",
"email": "john.wellbelove@etlcpp.com"
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Embedded Template Library
version=20.38.16
version=20.38.17
author= John Wellbelove <john.wellbelove@etlcpp.com>
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
license=MIT
Expand Down
5 changes: 5 additions & 0 deletions support/Release notes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
===============================================================================
20.38.17

#895 Removed std algorithm calls from algorithm.h

===============================================================================
20.38.16

Fixes:
Expand Down
13 changes: 13 additions & 0 deletions test/test_type_traits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ namespace
NotDefaultConstructible(NotDefaultConstructible&&) = delete;
NotDefaultConstructible& operator =(NotDefaultConstructible&) = delete;
};

// A function to test etl::type_identity.
template <typename T>
T type_identity_test_add(T first, typename etl::type_identity<T>::type second)
{
return first + second;
}
}

// Definitions for when the STL and compiler built-ins are not available.
Expand Down Expand Up @@ -1320,4 +1327,10 @@ namespace
CHECK_FALSE(bool(etl::is_base_of_all<Base, D1, D2, D3, D4>::value));
#endif
}

//*************************************************************************
TEST(test_type_identity)
{
CHECK_CLOSE(type_identity_test_add(1.5f, 2), 3.5f, 0.01f);
}
}
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.38.16
20.38.17

0 comments on commit e159a6b

Please sign in to comment.