Prefer "using" over "typedef"

This commit is contained in:
Antony Polukhin
2024-12-17 16:37:40 +03:00
parent 8a860e05d0
commit 35a71f0701
4 changed files with 8 additions and 8 deletions

View File

@@ -150,10 +150,10 @@ This includes C++ built-in pointers, `std::shared_ptr`,
class Banana : public Fruit {};
// Use one of these:
typedef Fruit* FruitPtr;
typedef std::shared_ptr<Fruit> FruitPtr;
typedef boost::shared_ptr<Fruit> FruitPtr;
typedef boost::intrusive_ptr<Fruit> FruitPtr;
using FruitPtr = Fruit*;
using FruitPtr = std::shared_ptr<Fruit>;
using FruitPtr = boost::shared_ptr<Fruit>;
using FruitPtr = boost::intrusive_ptr<Fruit>;
void f(FruitPtr fruit) {
// ... logic which leads us to believe it is a banana

View File

@@ -17,7 +17,7 @@ namespace detail {
template<class T> struct icast_identity
{
typedef T type;
using type = T;
};
} // namespace detail

View File

@@ -113,7 +113,7 @@ namespace boost
std::is_reference<Target>::value, Target
>::type polymorphic_downcast(Source& x)
{
typedef typename std::remove_reference<Target>::type* target_pointer_type;
using target_pointer_type = typename std::remove_reference<Target>::type*;
return *boost::polymorphic_downcast<target_pointer_type>(
std::addressof(x)
);

View File

@@ -18,8 +18,8 @@ struct foo
operator long() const { return 0; }
};
typedef type<long> long_type;
typedef type<foo> foo_type;
using long_type = type<long>;
using foo_type = type<foo>;
int main()
{