Deployed type trait aliases
This commit is contained in:
parent
70d37c4389
commit
4d17fa12cf
11 changed files with 81 additions and 75 deletions
|
@ -28,6 +28,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "global.hpp"
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include <climits>
|
||||
#include <ctime>
|
||||
|
@ -172,7 +173,7 @@ public:
|
|||
config_attribute_value& operator=(const std::string &v);
|
||||
config_attribute_value& operator=(const t_string &v);
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_base_of<enum_tag, T>::value, config_attribute_value &>::type operator=(const T &v)
|
||||
utils::enable_if_t<std::is_base_of<enum_tag, T>::value, config_attribute_value&> operator=(const T &v)
|
||||
{
|
||||
return operator=(T::enum_to_string(v));
|
||||
}
|
||||
|
@ -192,7 +193,7 @@ public:
|
|||
TODO: Fix this in c++11 using constexpr types.
|
||||
*/
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_base_of<enum_tag, T>::value, T>::type to_enum(const T &v) const
|
||||
utils::enable_if_t<std::is_base_of<enum_tag, T>::value, T> to_enum(const T &v) const
|
||||
{
|
||||
return T::string_to_enum(this->str(), v);
|
||||
}
|
||||
|
@ -219,14 +220,14 @@ public:
|
|||
// These function prevent t_string creation in case of c["a"] == "b" comparisons.
|
||||
// The templates are needed to prevent using these function in case of c["a"] == 0 comparisons.
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_same<const std::string, typename std::add_const<T>::type>::value, bool>::type
|
||||
utils::enable_if_t<std::is_same<const std::string, utils::add_const_t<T>>::value, bool>
|
||||
friend operator==(const config_attribute_value &val, const T &str)
|
||||
{
|
||||
return val.equals(str);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_same<const char*, T>::value, bool>::type
|
||||
utils::enable_if_t<std::is_same<const char*, T>::value, bool>
|
||||
friend operator==(const config_attribute_value& val, T str)
|
||||
{
|
||||
return val.equals(std::string(str));
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "serialization/unicode_types.hpp"
|
||||
|
||||
#include "utils/functional.hpp"
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include <SDL_events.h>
|
||||
|
||||
|
@ -329,7 +330,7 @@ public:
|
|||
* @param position The position to place the callback.
|
||||
*/
|
||||
template <ui_event E>
|
||||
typename std::enable_if<has_key<set_event, E>::value>::type
|
||||
utils::enable_if_t<has_key<set_event, E>::value>
|
||||
connect_signal(const signal_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -347,7 +348,7 @@ public:
|
|||
* was added in front or back.)
|
||||
*/
|
||||
template <ui_event E>
|
||||
typename std::enable_if<has_key<set_event, E>::value>::type
|
||||
utils::enable_if_t<has_key<set_event, E>::value>
|
||||
disconnect_signal(const signal_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -362,7 +363,7 @@ public:
|
|||
* @param position The position to place the callback.
|
||||
*/
|
||||
template <ui_event E>
|
||||
typename std::enable_if<has_key<set_event_mouse, E>::value>::type
|
||||
utils::enable_if_t<has_key<set_event_mouse, E>::value>
|
||||
connect_signal(const signal_mouse_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -380,7 +381,7 @@ public:
|
|||
* was added in front or back.)
|
||||
*/
|
||||
template <ui_event E>
|
||||
typename std::enable_if<has_key<set_event_mouse, E>::value>::type
|
||||
utils::enable_if_t<has_key<set_event_mouse, E>::value>
|
||||
disconnect_signal(const signal_mouse_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -395,7 +396,7 @@ public:
|
|||
* @param position The position to place the callback.
|
||||
*/
|
||||
template <ui_event E>
|
||||
typename std::enable_if<has_key<set_event_keyboard, E>::value>::type
|
||||
utils::enable_if_t<has_key<set_event_keyboard, E>::value>
|
||||
connect_signal(const signal_keyboard_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -413,7 +414,7 @@ public:
|
|||
* was added in front or back.)
|
||||
*/
|
||||
template <ui_event E>
|
||||
typename std::enable_if<has_key<set_event_keyboard, E>::value>::type
|
||||
utils::enable_if_t<has_key<set_event_keyboard, E>::value>
|
||||
disconnect_signal(const signal_keyboard_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -428,7 +429,7 @@ public:
|
|||
* @param position The position to place the callback.
|
||||
*/
|
||||
template <ui_event E>
|
||||
typename std::enable_if<has_key<set_event_touch, E>::value>::type
|
||||
utils::enable_if_t<has_key<set_event_touch, E>::value>
|
||||
connect_signal(const signal_touch_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -446,7 +447,7 @@ public:
|
|||
* was added in front or back.)
|
||||
*/
|
||||
template <ui_event E>
|
||||
typename std::enable_if<has_key<set_event_touch, E>::value>::type
|
||||
utils::enable_if_t<has_key<set_event_touch, E>::value>
|
||||
disconnect_signal(const signal_touch_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -464,7 +465,7 @@ public:
|
|||
* and shouldn't be used.
|
||||
*/
|
||||
template <ui_event E>
|
||||
typename std::enable_if<has_key<set_event_notification, E>::value>::type
|
||||
utils::enable_if_t<has_key<set_event_notification, E>::value>
|
||||
connect_signal(const signal_notification_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -487,7 +488,7 @@ public:
|
|||
* front_pre_child)
|
||||
*/
|
||||
template <ui_event E>
|
||||
typename std::enable_if<has_key<set_event_notification, E>::value>::type
|
||||
utils::enable_if_t<has_key<set_event_notification, E>::value>
|
||||
disconnect_signal(const signal_notification_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -505,7 +506,7 @@ public:
|
|||
* and shouldn't be used.
|
||||
*/
|
||||
template <ui_event E>
|
||||
typename std::enable_if<has_key<set_event_message, E>::value>::type
|
||||
utils::enable_if_t<has_key<set_event_message, E>::value>
|
||||
connect_signal(const signal_message_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -528,7 +529,7 @@ public:
|
|||
* front_pre_child)
|
||||
*/
|
||||
template <ui_event E>
|
||||
typename std::enable_if<has_key<set_event_message, E>::value>::type
|
||||
utils::enable_if_t<has_key<set_event_message, E>::value>
|
||||
disconnect_signal(const signal_message_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -543,7 +544,7 @@ public:
|
|||
* @param position The position to place the callback.
|
||||
*/
|
||||
template <ui_event E>
|
||||
typename std::enable_if<has_key<set_event_raw_event, E>::value>::type
|
||||
utils::enable_if_t<has_key<set_event_raw_event, E>::value>
|
||||
connect_signal(const signal_raw_event_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
@ -561,7 +562,7 @@ public:
|
|||
* was added in front or back.)
|
||||
*/
|
||||
template <ui_event E>
|
||||
typename std::enable_if<has_key<set_event_raw_event, E>::value>::type
|
||||
utils::enable_if_t<has_key<set_event_raw_event, E>::value>
|
||||
disconnect_signal(const signal_raw_event_function& signal,
|
||||
const queue_position position = back_child)
|
||||
{
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "gui/core/event/dispatcher.hpp"
|
||||
|
||||
#include "gui/widgets/widget.hpp"
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include <SDL_events.h>
|
||||
|
||||
|
@ -60,8 +61,7 @@ struct dispatcher_implementation
|
|||
* dispatcher::signal_type<FUNCTION> \
|
||||
*/ \
|
||||
template<typename F> \
|
||||
static typename std::enable_if<std::is_same<F, FUNCTION>::value, \
|
||||
dispatcher::signal_type<FUNCTION>>::type& \
|
||||
static utils::enable_if_t<std::is_same<F, FUNCTION>::value, dispatcher::signal_type<FUNCTION>>& \
|
||||
event_signal(dispatcher& dispatcher, const ui_event event) \
|
||||
{ \
|
||||
return dispatcher.QUEUE.queue[event]; \
|
||||
|
@ -81,8 +81,7 @@ struct dispatcher_implementation
|
|||
* dispatcher::signal_type<FUNCTION> \
|
||||
*/ \
|
||||
template<typename K> \
|
||||
static typename std::enable_if<boost::mpl::has_key<SET, K>::value, \
|
||||
dispatcher::signal_type<FUNCTION>>::type& \
|
||||
static utils::enable_if_t<boost::mpl::has_key<SET, K>::value, dispatcher::signal_type<FUNCTION>>& \
|
||||
event_signal(dispatcher& dispatcher, const ui_event event) \
|
||||
{ \
|
||||
return dispatcher.QUEUE.queue[event]; \
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "gui/widgets/selectable_item.hpp"
|
||||
|
||||
#include "utils/functional.hpp"
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
|
@ -27,7 +28,7 @@ namespace gui2 {
|
|||
* Default value getter for selectable widgets (like toggle buttons)
|
||||
*/
|
||||
template<typename T>
|
||||
static inline typename std::enable_if<std::is_base_of<selectable_item, T>::value, std::string>::type
|
||||
static inline utils::enable_if_t<std::is_base_of<selectable_item, T>::value, std::string>
|
||||
default_value_getter(T& w)
|
||||
{
|
||||
return w.get_value_bool() ? _("yes") : _("no");
|
||||
|
@ -37,7 +38,7 @@ default_value_getter(T& w)
|
|||
* Default value getter for integer-based widgets (like sliders)
|
||||
*/
|
||||
template<typename T>
|
||||
static inline typename std::enable_if<std::is_base_of<integer_selector, T>::value, std::string>::type
|
||||
static inline utils::enable_if_t<std::is_base_of<integer_selector, T>::value, std::string>
|
||||
default_value_getter(T& w)
|
||||
{
|
||||
return w.get_value_label();
|
||||
|
|
|
@ -47,6 +47,8 @@
|
|||
|
||||
#include "global.hpp"
|
||||
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
|
@ -169,8 +171,7 @@ struct lexical_caster<
|
|||
std::string
|
||||
, From
|
||||
, void
|
||||
, typename std::enable_if<std::is_integral<
|
||||
typename std::remove_pointer<From>::type>::value >::type
|
||||
, utils::enable_if_t<std::is_integral<utils::remove_pointer_t<From>>::value>
|
||||
>
|
||||
{
|
||||
std::string operator()(From value, boost::optional<std::string>) const
|
||||
|
@ -195,8 +196,7 @@ struct lexical_caster<
|
|||
long long
|
||||
, From
|
||||
, void
|
||||
, typename std::enable_if<boost::mpl::has_key<boost::mpl::set<
|
||||
char*, const char*> , From>::value >::type
|
||||
, utils::enable_if_t<boost::mpl::has_key<boost::mpl::set<char*, const char*> , From>::value>
|
||||
>
|
||||
{
|
||||
long long operator()(From value, boost::optional<long long> fallback) const
|
||||
|
@ -251,9 +251,8 @@ template <class To, class From>
|
|||
struct lexical_caster<
|
||||
To
|
||||
, From
|
||||
, typename std::enable_if<std::is_integral<To>::value && std::is_signed<To>::value && !std::is_same<To, long long>::value >::type
|
||||
, typename std::enable_if<boost::mpl::has_key<boost::mpl::set<
|
||||
char*, const char*> , From>::value >::type
|
||||
, utils::enable_if_t<std::is_integral<To>::value && std::is_signed<To>::value && !std::is_same<To, long long>::value>
|
||||
, utils::enable_if_t<boost::mpl::has_key<boost::mpl::set<char*, const char*> , From>::value>
|
||||
>
|
||||
{
|
||||
To operator()(From value, boost::optional<To> fallback) const
|
||||
|
@ -277,7 +276,7 @@ template <class To>
|
|||
struct lexical_caster<
|
||||
To
|
||||
, std::string
|
||||
, typename std::enable_if<std::is_integral<To>::value && std::is_signed<To>::value && !std::is_same<To, long long>::value >::type
|
||||
, utils::enable_if_t<std::is_integral<To>::value && std::is_signed<To>::value && !std::is_same<To, long long>::value>
|
||||
>
|
||||
{
|
||||
To operator()(const std::string& value, boost::optional<To> fallback) const
|
||||
|
@ -310,9 +309,8 @@ template <class To, class From>
|
|||
struct lexical_caster<
|
||||
To
|
||||
, From
|
||||
, typename std::enable_if<std::is_floating_point<To>::value >::type
|
||||
, typename std::enable_if<boost::mpl::has_key<boost::mpl::set<
|
||||
char*, const char*> , From>::value >::type
|
||||
, utils::enable_if_t<std::is_floating_point<To>::value>
|
||||
, utils::enable_if_t<boost::mpl::has_key<boost::mpl::set<char*, const char*> , From>::value>
|
||||
>
|
||||
{
|
||||
To operator()(From value, boost::optional<To> fallback) const
|
||||
|
@ -336,7 +334,7 @@ template <class To>
|
|||
struct lexical_caster<
|
||||
To
|
||||
, std::string
|
||||
, typename std::enable_if<std::is_floating_point<To>::value >::type
|
||||
, utils::enable_if_t<std::is_floating_point<To>::value>
|
||||
>
|
||||
{
|
||||
To operator()(const std::string& value, boost::optional<To> fallback) const
|
||||
|
@ -381,8 +379,7 @@ struct lexical_caster<
|
|||
unsigned long long
|
||||
, From
|
||||
, void
|
||||
, typename std::enable_if<boost::mpl::has_key<boost::mpl::set<
|
||||
char*, const char*> , From>::value >::type
|
||||
, utils::enable_if_t<boost::mpl::has_key<boost::mpl::set<char*, const char*> , From>::value>
|
||||
>
|
||||
{
|
||||
unsigned long long operator()(From value, boost::optional<unsigned long long> fallback) const
|
||||
|
@ -438,9 +435,8 @@ template <class To, class From>
|
|||
struct lexical_caster<
|
||||
To
|
||||
, From
|
||||
, typename std::enable_if<std::is_unsigned<To>::value && !std::is_same<To, unsigned long long>::value >::type
|
||||
, typename std::enable_if<boost::mpl::has_key<boost::mpl::set<
|
||||
char*, const char*> , From>::value >::type
|
||||
, utils::enable_if_t<std::is_unsigned<To>::value && !std::is_same<To, unsigned long long>::value>
|
||||
, utils::enable_if_t<boost::mpl::has_key<boost::mpl::set<char*, const char*> , From>::value>
|
||||
>
|
||||
{
|
||||
To operator()(From value, boost::optional<To> fallback) const
|
||||
|
@ -464,7 +460,7 @@ template <class To>
|
|||
struct lexical_caster<
|
||||
To
|
||||
, std::string
|
||||
, typename std::enable_if<std::is_unsigned<To>::value >::type
|
||||
, utils::enable_if_t<std::is_unsigned<To>::value>
|
||||
>
|
||||
{
|
||||
To operator()(const std::string& value, boost::optional<To> fallback) const
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "units/unit.hpp"
|
||||
#include "units/attack_type.hpp"
|
||||
#include "utils/const_clone.hpp"
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include "lua/lauxlib.h"
|
||||
#include "lua/lua.h" // for lua_State, lua_settop, etc
|
||||
|
@ -81,7 +82,7 @@ attack_type& luaW_checkweapon(lua_State* L, int idx)
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
using attack_ptr_in = std::shared_ptr<typename utils::const_clone<attack_type, typename std::remove_pointer<T>::type>::type>;
|
||||
using attack_ptr_in = std::shared_ptr<utils::const_clone_t<attack_type, utils::remove_pointer_t<T>>>;
|
||||
|
||||
// Note that these two templates are designed on the assumption that T is either unit or unit_type
|
||||
template<typename T>
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "lua/lauxlib.h"
|
||||
#include "lua/lua.h"
|
||||
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
class enum_tag;
|
||||
|
@ -81,18 +83,18 @@ namespace lua_check_impl
|
|||
template<typename T>
|
||||
struct remove_constref
|
||||
{
|
||||
typedef typename std::remove_const<typename std::remove_reference<typename std::remove_const<T>::type>::type>::type type;
|
||||
typedef utils::remove_const_t<utils::remove_reference_t<utils::remove_const_t<T>>> type;
|
||||
};
|
||||
|
||||
//std::string
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_same<T, std::string>::value, std::string>::type
|
||||
utils::enable_if_t<std::is_same<T, std::string>::value, std::string>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
return luaL_checkstring(L, n);
|
||||
}
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_same<T, std::string>::value, void>::type
|
||||
utils::enable_if_t<std::is_same<T, std::string>::value, void>
|
||||
lua_push(lua_State *L, const T& val)
|
||||
{
|
||||
lua_pushlstring(L, val.c_str(), val.size());
|
||||
|
@ -100,13 +102,13 @@ namespace lua_check_impl
|
|||
|
||||
//config
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_same<T, config>::value, config>::type
|
||||
utils::enable_if_t<std::is_same<T, config>::value, config>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
return luaW_checkconfig(L, n);
|
||||
}
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_same<T, config>::value, void>::type
|
||||
utils::enable_if_t<std::is_same<T, config>::value, void>
|
||||
lua_push(lua_State *L, const config& val)
|
||||
{
|
||||
luaW_pushconfig(L, val);
|
||||
|
@ -114,13 +116,13 @@ namespace lua_check_impl
|
|||
|
||||
//location
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_same<T, map_location>::value, map_location>::type
|
||||
utils::enable_if_t<std::is_same<T, map_location>::value, map_location>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
return luaW_checklocation(L, n);
|
||||
}
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_same<T, map_location>::value, void>::type
|
||||
utils::enable_if_t<std::is_same<T, map_location>::value, void>
|
||||
lua_push(lua_State *L, const map_location& val)
|
||||
{
|
||||
luaW_pushlocation(L, val);
|
||||
|
@ -128,7 +130,7 @@ namespace lua_check_impl
|
|||
|
||||
//enums generated by MAKE_ENUM
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_base_of<enum_tag, T>::value, T>::type
|
||||
utils::enable_if_t<std::is_base_of<enum_tag, T>::value, T>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
T val;
|
||||
|
@ -140,7 +142,7 @@ namespace lua_check_impl
|
|||
return val;
|
||||
}
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_base_of<enum_tag, T>::value, void>::type
|
||||
utils::enable_if_t<std::is_base_of<enum_tag, T>::value, void>
|
||||
lua_push(lua_State *L, T val)
|
||||
{
|
||||
lua_check_impl::lua_push(L, val.to_string());
|
||||
|
@ -148,13 +150,13 @@ namespace lua_check_impl
|
|||
|
||||
//t_string
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_same<T, t_string>::value, t_string>::type
|
||||
utils::enable_if_t<std::is_same<T, t_string>::value, t_string>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
return luaW_checktstring(L, n);
|
||||
}
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_same<T, t_string>::value, void>::type
|
||||
utils::enable_if_t<std::is_same<T, t_string>::value, void>
|
||||
lua_push(lua_State *L, const t_string& val)
|
||||
{
|
||||
luaW_pushtstring(L, val);
|
||||
|
@ -162,13 +164,13 @@ namespace lua_check_impl
|
|||
|
||||
//bool
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_same<T, bool>::value, bool>::type
|
||||
utils::enable_if_t<std::is_same<T, bool>::value, bool>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
return luaW_toboolean(L, n);
|
||||
}
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_same<T, bool>::value, void>::type
|
||||
utils::enable_if_t<std::is_same<T, bool>::value, void>
|
||||
lua_push(lua_State *L, bool val)
|
||||
{
|
||||
lua_pushboolean(L, val);
|
||||
|
@ -176,13 +178,13 @@ namespace lua_check_impl
|
|||
|
||||
//double, float
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_floating_point<T>::value, T>::type
|
||||
utils::enable_if_t<std::is_floating_point<T>::value, T>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
return luaL_checknumber(L, n);
|
||||
}
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_floating_point<T>::value, void>::type
|
||||
utils::enable_if_t<std::is_floating_point<T>::value, void>
|
||||
lua_push(lua_State *L, T val)
|
||||
{
|
||||
lua_pushnumber(L, val);
|
||||
|
@ -190,14 +192,14 @@ namespace lua_check_impl
|
|||
|
||||
//integer types
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_integral<T>::value && !std::is_same<T, bool>::value, T>::type
|
||||
utils::enable_if_t<std::is_integral<T>::value && !std::is_same<T, bool>::value, T>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
return luaL_checkinteger(L, n);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_integral<T>::value && !std::is_same<T, bool>::value, void>::type
|
||||
utils::enable_if_t<std::is_integral<T>::value && !std::is_same<T, bool>::value, void>
|
||||
lua_push(lua_State *L, T val)
|
||||
{
|
||||
lua_pushnumber(L, val);
|
||||
|
@ -206,7 +208,7 @@ namespace lua_check_impl
|
|||
//std::pair
|
||||
//Not sure if the not_<is_const> is required; only (maybe) if std::map matches is_container
|
||||
template<typename T>
|
||||
typename std::enable_if<is_pair<T>::value && !std::is_const<typename T::first_type>::value, T>::type
|
||||
utils::enable_if_t<is_pair<T>::value && !std::is_const<typename T::first_type>::value, T>
|
||||
lua_check(lua_State *L, int n)
|
||||
{
|
||||
T result;
|
||||
|
@ -220,7 +222,7 @@ namespace lua_check_impl
|
|||
return result;
|
||||
}
|
||||
template<typename T>
|
||||
typename std::enable_if<is_pair<T>::value && !std::is_const<typename T::first_type>::value, void>::type
|
||||
utils::enable_if_t<is_pair<T>::value && !std::is_const<typename T::first_type>::value, void>
|
||||
lua_push(lua_State *L, const T& val)
|
||||
{
|
||||
lua_newtable(L);
|
||||
|
@ -232,7 +234,7 @@ namespace lua_check_impl
|
|||
|
||||
//std::vector and similar but not std::string
|
||||
template<typename T>
|
||||
typename std::enable_if<is_container<T>::value && !std::is_same<T, std::string>::value, T>::type
|
||||
utils::enable_if_t<is_container<T>::value && !std::is_same<T, std::string>::value, T>
|
||||
lua_check(lua_State * L, int n)
|
||||
{
|
||||
if (lua_istable(L, n))
|
||||
|
@ -262,10 +264,10 @@ namespace lua_check_impl
|
|||
|
||||
//also accepts things like std::vector<int>() | std::adaptors::transformed(..)
|
||||
template<typename T>
|
||||
typename std::enable_if<
|
||||
utils::enable_if_t<
|
||||
is_container<T>::value && !std::is_same<T, std::string>::value && !is_map<T>::value
|
||||
, void
|
||||
>::type
|
||||
>
|
||||
lua_push(lua_State * L, const T& list )
|
||||
{
|
||||
// NOTE: T might be some boost::iterator_range type where size might be < 0. (unfortunately in this case size() does not return T::size_type)
|
||||
|
@ -281,7 +283,7 @@ namespace lua_check_impl
|
|||
|
||||
//accepts std::map TODO: add a check function for that
|
||||
template<typename T>
|
||||
typename std::enable_if<is_map<T>::value, void>::type
|
||||
utils::enable_if_t<is_map<T>::value, void>
|
||||
lua_push(lua_State * L, const T& map )
|
||||
{
|
||||
lua_newtable(L);
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#include "units/ptr.hpp"
|
||||
#include "units/types.hpp"
|
||||
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include <bitset>
|
||||
#include <boost/dynamic_bitset_fwd.hpp>
|
||||
#include <boost/ptr_container/ptr_vector.hpp>
|
||||
|
@ -976,7 +978,7 @@ public:
|
|||
struct upkeep_type_visitor : public boost::static_visitor<std::string>
|
||||
{
|
||||
template<typename T>
|
||||
typename std::enable_if<!std::is_same<int, T>::value, std::string>::type
|
||||
utils::enable_if_t<!std::is_same<int, T>::value, std::string>
|
||||
operator()(T&) const
|
||||
{
|
||||
// Any special upkeep type should have an associated @ref type getter in its helper struct.
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace utils
|
||||
|
@ -37,22 +39,22 @@ struct const_clone
|
|||
{
|
||||
static const bool is_source_const =
|
||||
std::is_const<
|
||||
typename std::remove_pointer<
|
||||
typename std::remove_reference<S>::type
|
||||
>::type
|
||||
utils::remove_pointer_t<
|
||||
utils::remove_reference_t<S>
|
||||
>
|
||||
>::value;
|
||||
|
||||
/** The destination type, possibly const qualified. */
|
||||
using type =
|
||||
typename std::conditional<is_source_const, const D, D>::type;
|
||||
utils::conditional_t<is_source_const, const D, D>;
|
||||
|
||||
/** A reference to the destination type, possibly const qualified. */
|
||||
using reference =
|
||||
typename std::conditional<is_source_const, const D&, D&>::type;
|
||||
utils::conditional_t<is_source_const, const D&, D&>;
|
||||
|
||||
/** A pointer to the destination type, possibly const qualified. */
|
||||
using pointer =
|
||||
typename std::conditional<is_source_const, const D*, D*>::type;
|
||||
utils::conditional_t<is_source_const, const D*, D*>;
|
||||
};
|
||||
|
||||
template<typename D, typename S>
|
||||
|
|
|
@ -39,7 +39,7 @@ typename V::result_t apply_visitor(typename V::param_t state, T&&... args)
|
|||
static_assert(std::is_base_of<
|
||||
info_visitor_base<
|
||||
typename V::result_t,
|
||||
typename std::remove_reference<typename V::param_t>::type>,
|
||||
utils::remove_reference_t<typename V::param_t>>,
|
||||
V>::value, "Invalid visitor type.");
|
||||
|
||||
// Create the visitor.
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "config.hpp"
|
||||
#include "utils/type_trait_aliases.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
@ -99,7 +100,7 @@ public:
|
|||
: variable_info<V>(name, game_vars)
|
||||
{
|
||||
static_assert(!std::is_same<
|
||||
variable_info_implementation::vi_policy_const, typename std::remove_const<V>::type>::value,
|
||||
variable_info_implementation::vi_policy_const, utils::remove_const_t<V>>::value,
|
||||
"variable_info_mutable cannot be specialized with 'vi_policy_const'"
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue