Skip to content

Commit

Permalink
Merge pull request #30801 from jbytheway/typedef_to_using
Browse files Browse the repository at this point in the history
Replace typedef with using
  • Loading branch information
ZhilkinSerg authored May 24, 2019
2 parents e67819e + 98103e0 commit a382891
Show file tree
Hide file tree
Showing 65 changed files with 144 additions and 148 deletions.
2 changes: 1 addition & 1 deletion src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct act_item {
};

// TODO: Deliberately unified with multidrop. Unify further.
typedef std::list<std::pair<int, int>> drop_indexes;
using drop_indexes = std::list<std::pair<int, int>>;

static bool same_type( const std::list<item> &items )
{
Expand Down
2 changes: 1 addition & 1 deletion src/advanced_inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ bool advanced_inventory_pane::is_filtered( const item &it ) const
}

// roll our own, to handle moving stacks better
typedef std::vector<std::list<item *>> itemstack;
using itemstack = std::vector<std::list<item *> >;

template <typename T>
static itemstack i_stacked( T items )
Expand Down
2 changes: 1 addition & 1 deletion src/advanced_inv.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class item_category;
* Most members are used only for sorting.
*/
struct advanced_inv_listitem {
typedef std::string itype_id;
using itype_id = std::string;
/**
* Index of the item in the itemstack.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/cursesport.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ namespace cata_cursesport
using base_color = catacurses::base_color;

//a pair of colors[] indexes, foreground and background
typedef struct {
struct pairs {
base_color FG;
base_color BG;
} pairs;
};

//Individual lines, so that we can track changed lines
struct cursecell {
Expand Down
2 changes: 1 addition & 1 deletion src/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ static std::string windows_version()

if( !success ) {
output = "";
typedef LONG( WINAPI * RtlGetVersion )( PRTL_OSVERSIONINFOW );
using RtlGetVersion = LONG( WINAPI * )( PRTL_OSVERSIONINFOW );
const HMODULE handle_ntdll = GetModuleHandleA( "ntdll" );
if( handle_ntdll != nullptr ) {
// Use union-based type-punning to convert function pointer
Expand Down
4 changes: 2 additions & 2 deletions src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class map_item_stack;
struct WORLD;
class save_t;

typedef WORLD *WORLDPTR;
using WORLDPTR = WORLD *;
class overmap;
class event_manager;

Expand All @@ -111,7 +111,7 @@ struct visibility_variables;
class scent_map;
class loading_ui;

typedef std::function<bool( const item & )> item_filter;
using item_filter = std::function<bool ( const item & )>;

enum peek_act : int {
PA_BLIND_THROW
Expand Down
4 changes: 2 additions & 2 deletions src/game_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ static const trait_id trait_NOPAIN( "NOPAIN" );

class Character;

typedef std::function<bool( const item & )> item_filter;
typedef std::function<bool( const item_location & )> item_location_filter;
using item_filter = std::function<bool ( const item & )>;
using item_location_filter = std::function<bool ( const item_location & )>;

namespace
{
Expand Down
2 changes: 1 addition & 1 deletion src/game_inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class player;
class salvage_actor;
class repair_item_actor;

typedef std::function<bool( const item_location & )> item_location_filter;
using item_location_filter = std::function<bool ( const item_location & )>;

class inventory_filter_preset : public inventory_selector_preset
{
Expand Down
2 changes: 1 addition & 1 deletion src/harvest.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "string_id.h"
#include "type_id.h"

typedef std::string itype_id;
using itype_id = std::string;
class JsonObject;

// Could be reused for butchery
Expand Down
10 changes: 5 additions & 5 deletions src/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ class JsonIn;
class DynamicDataLoader
{
public:
typedef std::string type_string;
typedef std::map<type_string, std::function<void( JsonObject &, const std::string &, const std::string &, const std::string & )>>
t_type_function_map;
typedef std::vector<std::string> str_vec;
using type_string = std::string;
using t_type_function_map =
std::map<type_string, std::function<void( JsonObject &, const std::string &, const std::string &, const std::string & )>>;
using str_vec = std::vector<std::string>;

/**
* JSON data dependent upon as-yet unparsed definitions
* first: JSON data, second: source identifier
*/
typedef std::list<std::pair<std::string, std::string>> deferred_json;
using deferred_json = std::list<std::pair<std::string, std::string>>;

private:
bool finalized = false;
Expand Down
12 changes: 6 additions & 6 deletions src/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,16 @@ class input_manager
private:
friend class input_context;

typedef std::vector<input_event> t_input_event_list;
typedef std::map<std::string, action_attributes> t_actions;
typedef std::map<std::string, t_actions> t_action_contexts;
using t_input_event_list = std::vector<input_event>;
using t_actions = std::map<std::string, action_attributes>;
using t_action_contexts = std::map<std::string, t_actions>;
t_action_contexts action_contexts;
typedef std::map<std::string, std::string> t_string_string_map;
using t_string_string_map = std::map<std::string, std::string>;

typedef std::map<long, std::string> t_key_to_name_map;
using t_key_to_name_map = std::map<long, std::string>;
t_key_to_name_map keycode_to_keyname;
t_key_to_name_map gamepad_keycode_to_keyname;
typedef std::map<std::string, long> t_name_to_key_map;
using t_name_to_key_map = std::map<std::string, long>;
t_name_to_key_map keyname_to_keycode;

// See @ref get_previously_pressed_key
Expand Down
2 changes: 1 addition & 1 deletion src/int_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ template<typename T>
class int_id
{
public:
typedef int_id<T> This;
using This = int_id<T>;

/**
* Explicit constructor to make it stand out in the code, so one can easily search for all
Expand Down
12 changes: 6 additions & 6 deletions src/inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class JsonOut;
class player;
struct tripoint;

typedef std::list< std::list<item> > invstack;
typedef std::vector< std::list<item>* > invslice;
typedef std::vector< const std::list<item>* > const_invslice;
typedef std::vector< std::pair<std::list<item>*, int> > indexed_invslice;
typedef std::unordered_map< itype_id, std::list<const item *> > itype_bin;
typedef std::bitset<std::numeric_limits<char>::max()> invlets_bitset;
using invstack = std::list<std::list<item> >;
using invslice = std::vector<std::list<item> *>;
using const_invslice = std::vector<const std::list<item> *>;
using indexed_invslice = std::vector< std::pair<std::list<item>*, int> >;
using itype_bin = std::unordered_map< itype_id, std::list<const item *> >;
using invlets_bitset = std::bitset<std::numeric_limits<char>::max()>;

/**
* Wrapper to handled a set of valid "inventory" letters. "inventory" can be any set of
Expand Down
2 changes: 1 addition & 1 deletion src/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ namespace detail

template<class T, class R = void>
struct enable_if_type {
typedef R type;
using type = R;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7123,7 +7123,7 @@ bool item::can_holster( const item &obj, bool ignore ) const

std::string item::components_to_string() const
{
typedef std::map<std::string, int> t_count_map;
using t_count_map = std::map<std::string, int>;
t_count_map counts;
for( const auto &elem : components ) {
if( !elem.has_flag( "BYPRODUCT" ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/item_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void game::item_action_menu()

std::vector<std::tuple<item_action_id, std::string, std::string>> menu_items;
// Sorts menu items by action.
typedef decltype( menu_items )::iterator Iter;
using Iter = decltype( menu_items )::iterator;
const auto sort_menu = []( Iter from, Iter to ) {
std::sort( from, to, []( const std::tuple<item_action_id, std::string, std::string> &lhs,
const std::tuple<item_action_id, std::string, std::string> &rhs ) {
Expand Down
6 changes: 3 additions & 3 deletions src/item_action.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class player;
class item;
class JsonObject;

typedef std::string item_action_id;
typedef std::map< item_action_id, item * > item_action_map;
typedef std::map< item_action_id, item_action > action_map;
using item_action_id = std::string;
using item_action_map = std::map< item_action_id, item * >;
using action_map = std::map< item_action_id, item_action >;

class item_action
{
Expand Down
2 changes: 1 addition & 1 deletion src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

class player;

typedef std::set<std::string> t_string_set;
using t_string_set = std::set<std::string>;
static t_string_set item_blacklist;

static std::set<std::string> repair_actions;
Expand Down
8 changes: 4 additions & 4 deletions src/item_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ template <typename T> class optional;

bool item_is_blacklisted( const std::string &id );

typedef std::string Item_tag;
typedef std::string Group_tag;
typedef std::vector<item> Item_list;
using Item_tag = std::string;
using Group_tag = std::string;
using Item_list = std::vector<item>;

class Item_factory;
class JsonObject;
Expand Down Expand Up @@ -247,7 +247,7 @@ class Item_factory

mutable std::map<itype_id, std::unique_ptr<itype>> m_runtimes;

typedef std::map<Group_tag, std::unique_ptr<Item_spawn_data>> GroupMap;
using GroupMap = std::map<Group_tag, std::unique_ptr<Item_spawn_data>>;
GroupMap m_template_groups;

/** Checks that ammo is listed in ammunition_type::name().
Expand Down
22 changes: 11 additions & 11 deletions src/item_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include "optional.h"
#include "item.h"

typedef std::string Item_tag;
typedef std::string Group_tag;
using Item_tag = std::string;
using Group_tag = std::string;
class JsonObject;
class JsonIn;
class time_point;
Expand All @@ -30,7 +30,7 @@ item item_from( const Group_tag &group_id, const time_point &birthday );
*/
item item_from( const Group_tag &group_id );

typedef std::vector<item> ItemList;
using ItemList = std::vector<item>;
/**
* Create items from the given group. It creates as many items as the group definition requests.
* For example if the group is a distribution that only contains item ids it will create
Expand Down Expand Up @@ -101,8 +101,8 @@ Group_tag load_item_group( JsonIn &stream, const std::string &default_subtype );
class Item_spawn_data
{
public:
typedef std::vector<item> ItemList;
typedef std::vector<Item_tag> RecursionList;
using ItemList = std::vector<item>;
using RecursionList = std::vector<Item_tag>;

Item_spawn_data( int _probability ) : probability( _probability ) { }
virtual ~Item_spawn_data() = default;
Expand Down Expand Up @@ -209,11 +209,11 @@ class Item_modifier
class Single_item_creator : public Item_spawn_data
{
public:
typedef enum {
enum Type {
S_ITEM_GROUP,
S_ITEM,
S_NONE,
} Type;
};

Single_item_creator( const std::string &id, Type type, int probability );
~Single_item_creator() override = default;
Expand Down Expand Up @@ -242,11 +242,11 @@ class Single_item_creator : public Item_spawn_data
class Item_group : public Item_spawn_data
{
public:
typedef std::vector<item> ItemList;
typedef enum {
using ItemList = std::vector<item>;
enum Type {
G_COLLECTION,
G_DISTRIBUTION
} Type;
};

Item_group( Type type, int probability, int ammo_chance, int magazine_chance );
~Item_group() override = default;
Expand All @@ -260,7 +260,7 @@ class Item_group : public Item_spawn_data
* If type is G_DISTRIBUTION, probability is relative,
* the sum probability is sum_prob.
*/
typedef std::vector<std::unique_ptr<Item_spawn_data>> prop_list;
using prop_list = std::vector<std::unique_ptr<Item_spawn_data> >;

void add_item_entry( const Item_tag &itemid, int probability );
void add_group_entry( const Group_tag &groupid, int probability );
Expand Down
4 changes: 2 additions & 2 deletions src/itype.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ enum art_effect_active : int;
enum art_charge : int;
enum art_charge_req : int;
enum art_effect_passive : int;
typedef std::string itype_id;
using itype_id = std::string;

enum field_id : int;

Expand Down Expand Up @@ -345,7 +345,7 @@ struct islot_book {
return hidden;
}
};
typedef std::set<recipe_with_description_t> recipe_list_t;
using recipe_list_t = std::set<recipe_with_description_t>;
recipe_list_t recipes;
};

Expand Down
4 changes: 2 additions & 2 deletions src/iuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class monster;
template<typename T> class ret_val;
struct iteminfo;

typedef std::string itype_id;
using itype_id = std::string;
struct tripoint;

// iuse methods returning a bool indicating whether to consume a charge of the item being used.
Expand Down Expand Up @@ -237,7 +237,7 @@ struct washing_requirements {
};
washing_requirements washing_requirements_for_volume( units::volume );

typedef int ( iuse::*use_function_pointer )( player *, item *, bool, const tripoint & );
using use_function_pointer = int ( iuse::* )( player *, item *, bool, const tripoint & );

class iuse_actor
{
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct arg_handler {
//! called with the number of parameters after the flag was encountered, along with the array
//! of following parameters. It must return an integer indicating how many parameters were
//! consumed by the call or -1 to indicate that a required argument was missing.
typedef std::function<int( int, const char ** )> handler_method;
using handler_method = std::function<int ( int, const char ** )>;

const char *flag; //!< The commandline parameter to handle (e.g., "--seed").
const char *param_documentation; //!< Human readable description of this arguments parameter.
Expand Down
8 changes: 4 additions & 4 deletions src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ struct wrapped_vehicle {
vehicle *v;
};

typedef std::vector<wrapped_vehicle> VehicleList;
typedef std::string items_location;
using VehicleList = std::vector<wrapped_vehicle>;
using items_location = std::string;
class map;

enum ter_bitflags : int;
Expand Down Expand Up @@ -1588,8 +1588,8 @@ class map
* It's a really heinous function pointer so a typedef is the best
* solution in this instance.
*/
typedef bool ( *map_process_func )( item_stack &, std::list<item>::iterator &, const tripoint &,
const std::string &, float, temperature_flag );
using map_process_func = bool ( * )( item_stack &, std::list<item>::iterator &, const tripoint &,
const std::string &, float, temperature_flag );
private:

// Iterates over every item on the map, passing each item to the provided function.
Expand Down
2 changes: 1 addition & 1 deletion src/map_extras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ static void mx_clay_deposit( map &m, const tripoint &abs_sub )
}
}

typedef std::unordered_map<std::string, map_special_pointer> FunctionMap;
using FunctionMap = std::unordered_map<std::string, map_special_pointer>;
FunctionMap builtin_functions = {
{ "mx_null", mx_null },
{ "mx_house_wasp", mx_house_wasp },
Expand Down
Loading

0 comments on commit a382891

Please sign in to comment.