Skip to content

Commit

Permalink
Replace typedef by using
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanel committed Jun 10, 2021
1 parent b61f487 commit 843b90b
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 47 deletions.
18 changes: 9 additions & 9 deletions src/benchmark/sets_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ TypeStats TypeStats::_stats;

namespace {

typedef std::set<ComplexTriviallyRelocatableType> REFRelocType;
typedef std::set<ComplexNonTriviallyRelocatableType> REFNonRelocType;
typedef std::set<uint32_t> REFInt;
typedef std::unordered_set<uint32_t> REFUnoInt;
using REFRelocType = std::set<ComplexTriviallyRelocatableType>;
using REFNonRelocType = std::set<ComplexNonTriviallyRelocatableType>;
using REFInt = std::set<uint32_t>;
using REFUnoInt = std::unordered_set<uint32_t>;

typedef amc::FlatSet<ComplexTriviallyRelocatableType> AMCRelocType;
typedef amc::FlatSet<ComplexNonTriviallyRelocatableType> AMCNonRelocType;
typedef amc::FlatSet<uint32_t> AMCInt;
using AMCRelocType = amc::FlatSet<ComplexTriviallyRelocatableType>;
using AMCNonRelocType = amc::FlatSet<ComplexNonTriviallyRelocatableType>;
using AMCInt = amc::FlatSet<uint32_t>;

template <class SetType>
void InsertRandom(benchmark::State &state) {
Expand All @@ -48,7 +48,7 @@ void EraseRandom(benchmark::State &state) {
TypeStats::_stats = TypeStats();
uint32_t s = 0;
SetType elems;
typedef typename SetType::value_type ValueType;
using ValueType = typename SetType::value_type;
std::vector<ValueType> remainingElems;
for (uint32_t i = 0; i < InitNbInserts; ++i) {
elems.emplace(i);
Expand Down Expand Up @@ -76,7 +76,7 @@ void LookUp(benchmark::State &state) {
TypeStats::_stats = TypeStats();
uint32_t s = 0;
SetType elems;
typedef typename SetType::value_type ValueType;
using ValueType = typename SetType::value_type;
for (uint32_t i = 0; i < Size; ++i) {
elems.emplace(i);
}
Expand Down
22 changes: 11 additions & 11 deletions src/benchmark/vectors_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ TypeStats TypeStats::_stats;

namespace {

typedef amc::vector<ComplexTriviallyRelocatableType> AMCRelocType;
typedef amc::vector<ComplexNonTriviallyRelocatableType> AMCNonRelocType;
typedef amc::vector<uint32_t> AMCInt;
using AMCRelocType = amc::vector<ComplexTriviallyRelocatableType>;
using AMCNonRelocType = amc::vector<ComplexNonTriviallyRelocatableType>;
using AMCInt = amc::vector<uint32_t>;

typedef std::vector<ComplexTriviallyRelocatableType> REFRelocType;
typedef std::vector<ComplexNonTriviallyRelocatableType> REFNonRelocType;
typedef std::vector<uint32_t> REFInt;
using REFRelocType = std::vector<ComplexTriviallyRelocatableType>;
using REFNonRelocType = std::vector<ComplexNonTriviallyRelocatableType>;
using REFInt = std::vector<uint32_t>;

template <class VecType>
void InsertNElemsRandom(benchmark::State &state) {
Expand Down Expand Up @@ -53,7 +53,7 @@ void InsertNElemsRandom(benchmark::State &state) {

template <class VecType>
void InsertFromPointerRandom(benchmark::State &state) {
typedef typename VecType::value_type ValueType;
using ValueType = typename VecType::value_type;
TypeStats::_stats = TypeStats();
VecType v(1, 0);
std::array<ValueType, kMaxValue - 10> kTab;
Expand All @@ -75,7 +75,7 @@ void InsertFromPointerRandom(benchmark::State &state) {

template <class VecType>
void InsertFromForwardItRandom(benchmark::State &state) {
typedef typename VecType::value_type ValueType;
using ValueType = typename VecType::value_type;
TypeStats::_stats = TypeStats();
VecType v(1, 0);
std::array<ValueType, kMaxValue - 10> kTab;
Expand Down Expand Up @@ -123,7 +123,7 @@ void EraseRandom(benchmark::State &state) {

template <class VecType>
void AssignRandom(benchmark::State &state) {
typedef typename VecType::value_type ValueType;
using ValueType = typename VecType::value_type;
TypeStats::_stats = TypeStats();
VecType v;
std::iota(v.begin(), v.end(), 0);
Expand Down Expand Up @@ -164,7 +164,7 @@ void SwapRandom(benchmark::State &state) {

template <class VecType>
void Growing(benchmark::State &state) {
typedef typename VecType::size_type SizeType;
using SizeType = typename VecType::size_type;
TypeStats::_stats = TypeStats();

const SizeType kMaxSize = 10000U;
Expand All @@ -184,7 +184,7 @@ void Growing(benchmark::State &state) {

template <class VecType, unsigned TypicalMaxSize>
void CommonUsage(benchmark::State &state) {
typedef typename VecType::value_type ValueType;
using ValueType = typename VecType::value_type;
TypeStats::_stats = TypeStats();

uint32_t seed = 0;
Expand Down
26 changes: 13 additions & 13 deletions src/include/amc_memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ template <class T>
inline void construct_at_impl(T *pos, const T &v, NonTriviallyCopyableArray) {
int i = 0;
try {
typedef typename std::remove_reference<decltype(**pos)>::type ElemT;
using ElemT = typename std::remove_reference<decltype(**pos)>::type;
typedef
typename std::conditional<std::is_array<ElemT>::value, NonTriviallyCopyableArray, NonTriviallyCopyable>::type
TypeTraits;
Expand All @@ -89,7 +89,7 @@ template <class T>
inline void construct_at_impl(T *pos, T &&v, NonTriviallyCopyableArray) {
int i = 0;
try {
typedef typename std::remove_reference<decltype(**pos)>::type ElemT;
using ElemT = typename std::remove_reference<decltype(**pos)>::type;
typedef
typename std::conditional<std::is_array<ElemT>::value, NonTriviallyCopyableArray, NonTriviallyCopyable>::type
TypeTraits;
Expand Down Expand Up @@ -149,7 +149,7 @@ template <class ForwardIt>
void uninitialized_default_construct(ForwardIt first, ForwardIt last,
typename std::enable_if<!std::is_trivially_default_constructible<
typename std::iterator_traits<ForwardIt>::value_type>::value>::type * = 0) {
typedef typename std::iterator_traits<ForwardIt>::value_type Value;
using Value = typename std::iterator_traits<ForwardIt>::value_type;
ForwardIt current = first;
try {
for (; current != last; ++current) {
Expand All @@ -171,7 +171,7 @@ ForwardIt uninitialized_default_construct_n(
typename std::enable_if<
!std::is_trivially_default_constructible<typename std::iterator_traits<ForwardIt>::value_type>::value>::type * =
0) {
typedef typename std::iterator_traits<ForwardIt>::value_type Value;
using Value = typename std::iterator_traits<ForwardIt>::value_type;
ForwardIt current = first;
try {
for (; n > 0; (void)++current, --n) {
Expand Down Expand Up @@ -248,8 +248,8 @@ struct MemMove {};
// Type factory deducing the optimization mode from the 3 defined above.
template <class InputIt, class OutputIt, bool IsMemMovePossible>
struct ImplModeFactory {
typedef typename std::iterator_traits<InputIt>::value_type InputType;
typedef typename std::iterator_traits<OutputIt>::value_type OutputType;
using InputType = typename std::iterator_traits<InputIt>::value_type;
using OutputType = typename std::iterator_traits<OutputIt>::value_type;
typedef typename std::conditional<std::is_pointer<InputIt>::value && std::is_pointer<OutputIt>::value, MemMove,
MemMoveInALoop>::type MemMoveType;
typedef
Expand All @@ -275,15 +275,15 @@ inline OutputIt uninitialized_copy_impl(InputIt first, InputIt last, OutputIt de
template <class InputIt, class OutputIt>
inline OutputIt uninitialized_copy_impl(InputIt first, InputIt last, OutputIt dest, MemMoveInALoop) {
for (; first != last; ++dest, void(), ++first) {
typedef typename std::iterator_traits<InputIt>::value_type ValueType;
using ValueType = typename std::iterator_traits<InputIt>::value_type;
std::memcpy(std::addressof(*dest), std::addressof(*first), sizeof(ValueType));
}
return dest;
}

template <class InputIt, class OutputIt>
inline OutputIt uninitialized_copy_impl(InputIt first, InputIt last, OutputIt dest, MemMove) {
typedef typename std::iterator_traits<InputIt>::value_type ValueType;
using ValueType = typename std::iterator_traits<InputIt>::value_type;
typename std::iterator_traits<InputIt>::difference_type count = last - first;
if (count > 0) {
// We can use memcpy here as for uninitialized_copy, we know that ranges do not overlap
Expand All @@ -309,15 +309,15 @@ inline OutputIt uninitialized_copy_n_impl(InputIt first, Size count, OutputIt de
template <class InputIt, class Size, class OutputIt>
inline OutputIt uninitialized_copy_n_impl(InputIt first, Size count, OutputIt dest, MemMoveInALoop) {
for (; count > 0; ++dest, void(), ++first, --count) {
typedef typename std::iterator_traits<InputIt>::value_type ValueType;
using ValueType = typename std::iterator_traits<InputIt>::value_type;
std::memcpy(std::addressof(*dest), std::addressof(*first), sizeof(ValueType));
}
return dest;
}

template <class InputIt, class Size, class OutputIt>
inline OutputIt uninitialized_copy_n_impl(InputIt first, Size count, OutputIt dest, MemMove) {
typedef typename std::iterator_traits<InputIt>::value_type ValueType;
using ValueType = typename std::iterator_traits<InputIt>::value_type;
// We can use memcpy here as for uninitialized_copy, we know that ranges do not overlap
if (count > 0) {
std::memcpy(dest, first, count * sizeof(ValueType));
Expand Down Expand Up @@ -358,7 +358,7 @@ template <class InputIt, class Size, class OutputIt>
inline std::pair<InputIt, OutputIt> uninitialized_move_n_impl(InputIt first, Size count, OutputIt dest,
MemMoveInALoop) {
for (; count > 0; ++dest, void(), ++first, --count) {
typedef typename std::iterator_traits<InputIt>::value_type ValueType;
using ValueType = typename std::iterator_traits<InputIt>::value_type;
std::memcpy(std::addressof(*dest), std::addressof(*first), sizeof(ValueType));
}
return std::pair<InputIt, OutputIt>(first, dest);
Expand Down Expand Up @@ -447,7 +447,7 @@ inline OutputIt uninitialized_relocate_impl(InputIt first, InputIt last, OutputI

template <class InputIt, class OutputIt>
inline OutputIt uninitialized_relocate_impl(InputIt first, InputIt last, OutputIt dest, MemMove) {
typedef typename std::iterator_traits<InputIt>::value_type ValueType;
using ValueType = typename std::iterator_traits<InputIt>::value_type;
typename std::iterator_traits<InputIt>::difference_type count = last - first;
if (count > 0) {
#if __GNUC__ >= 8
Expand Down Expand Up @@ -481,7 +481,7 @@ inline std::pair<InputIt, OutputIt> uninitialized_relocate_n_impl(InputIt first,

template <class InputIt, class Size, class OutputIt>
inline std::pair<InputIt, OutputIt> uninitialized_relocate_n_impl(InputIt first, Size count, OutputIt dest, MemMove) {
typedef typename std::iterator_traits<InputIt>::value_type ValueType;
using ValueType = typename std::iterator_traits<InputIt>::value_type;
if (count > 0) {
#if __GNUC__ >= 8
// Do not raise class-memaccess warning for trivially relocatable types
Expand Down
8 changes: 4 additions & 4 deletions src/include/amc_type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ struct do_is_nothrow_swappable_impl {

template <typename T>
struct is_swappable_impl : public typetraits_details::do_is_swappable_impl {
typedef decltype(test<T>(0)) type;
using type = decltype(test<T>(0));
};

template <typename T>
struct is_nothrow_swappable_impl : public typetraits_details::do_is_nothrow_swappable_impl {
typedef decltype(test<T>(0)) type;
using type = decltype(test<T>(0));
};

template <typename T>
Expand All @@ -53,7 +53,7 @@ namespace typetraits_details {

template <typename... Ts>
struct make_void {
typedef void type;
using type = void;
};

template <typename T, typename = void>
Expand Down Expand Up @@ -93,7 +93,7 @@ struct is_trivially_relocatable_impl<T, true> : public std::is_same<typename T::
* is_trivially_relocatable<SomeStruct> in the same header as SomeStruct.
*
* You may also declare a type to be relocatable by defining
* `typedef std::true_type trivially_relocatable;`
* `using trivially_relocatable = std::true_type;`
* in the class declaration.
* */
template <typename T>
Expand Down
6 changes: 3 additions & 3 deletions src/test/sets_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TypeStats TypeStats::_stats;
template <typename T>
class SetListTest : public ::testing::Test {
public:
typedef typename std::list<T> List;
using List = typename std::list<T>;
};

typedef ::testing::Types<
Expand Down Expand Up @@ -294,7 +294,7 @@ TYPED_TEST(SetListTest, ComparisonOperators) {

#ifdef AMC_SMALLSET
TEST(SetTest, SmallSetSizeTest) {
typedef SmallSet<int, 12> SetType;
using SetType = SmallSet<int, 12>;
SetType s;
EXPECT_GT(s.max_size(), 12U);
constexpr int tab[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
Expand Down Expand Up @@ -331,7 +331,7 @@ TEST(SetTest, Relocatibility) {
template <typename T>
class SetListExtractTest : public ::testing::Test {
public:
typedef typename std::list<T> List;
using List = typename std::list<T>;
};

using SetsExtractType = ::testing::Types<FlatSet<NonCopyableType>, SmallSet<NonCopyableType, 2>,
Expand Down
4 changes: 2 additions & 2 deletions src/test/testtypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ struct ComplexType {
uint32_t _i;
};

typedef ComplexType<false> ComplexNonTriviallyRelocatableType;
typedef ComplexType<true> ComplexTriviallyRelocatableType;
using ComplexNonTriviallyRelocatableType = ComplexType<false>;
using ComplexTriviallyRelocatableType = ComplexType<true>;

struct NonTriviallyRelocatableType {
NonTriviallyRelocatableType(uint32_t i = 0) : _data(i) {}
Expand Down
10 changes: 5 additions & 5 deletions src/test/vectors_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TypeStats TypeStats::_stats;
template <typename T>
class VectorTest : public ::testing::Test {
public:
typedef typename std::list<T> List;
using List = typename std::list<T>;
};

typedef ::testing::Types<
Expand Down Expand Up @@ -170,7 +170,7 @@ TYPED_TEST(VectorTest, Main) {
template <typename T>
class VectorRefTest : public ::testing::Test {
public:
typedef typename std::list<T> List;
using List = typename std::list<T>;
};

// clang-format off
Expand Down Expand Up @@ -203,9 +203,9 @@ inline bool operator==(const VectorImpl<T, A, S, I, G> &lhs, const typename std:
}

TYPED_TEST(VectorRefTest, CompareToRefVector) {
typedef TypeParam VectorType;
typedef typename VectorType::value_type Type;
typedef typename std::vector<Type> RefVecType;
using VectorType = TypeParam;
using Type = typename VectorType::value_type;
using RefVecType = typename std::vector<Type>;

VectorType v(100U, 2);
RefVecType r(100U, 2);
Expand Down

0 comments on commit 843b90b

Please sign in to comment.