Further reduce template instantiations

This commit is contained in:
Vas Crabb 2016-03-04 16:46:34 +11:00
parent 05ce8f1be3
commit 5a5b787081
2 changed files with 18 additions and 38 deletions

View File

@ -14,19 +14,6 @@
#include <ctype.h>
//**************************************************************************
// COMPILE-TIME VALIDATION
//**************************************************************************
// if the following lines error during compile, your PTR64 switch is set incorrectly in the makefile
#ifdef PTR64
UINT8 your_ptr64_flag_is_wrong[(int)(sizeof(void *) - 7)];
#else
UINT8 your_ptr64_flag_is_wrong[(int)(5 - sizeof(void *))];
#endif
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
@ -350,9 +337,9 @@ void validity_checker::validate_core()
// check pointer size
#ifdef PTR64
if (sizeof(void *) != 8) osd_printf_error("PTR64 flag enabled, but was compiled for 32-bit target\n");
static_assert(sizeof(void *) == 8, "PTR64 flag enabled, but was compiled for 32-bit target\n");
#else
if (sizeof(void *) != 4) osd_printf_error("PTR64 flag not enabled, but was compiled for 64-bit target\n");
static_assert(sizeof(void *) == 4, "PTR64 flag not enabled, but was compiled for 64-bit target\n");
#endif
// TODO: check if this is actually working
@ -377,9 +364,6 @@ void validity_checker::validate_inlines()
#undef rand
volatile UINT64 testu64a = rand() ^ (rand() << 15) ^ ((UINT64)rand() << 30) ^ ((UINT64)rand() << 45);
volatile INT64 testi64a = rand() ^ (rand() << 15) ^ ((INT64)rand() << 30) ^ ((INT64)rand() << 45);
#ifdef PTR64
volatile INT64 testi64b = rand() ^ (rand() << 15) ^ ((INT64)rand() << 30) ^ ((INT64)rand() << 45);
#endif
volatile UINT32 testu32a = rand() ^ (rand() << 15);
volatile UINT32 testu32b = rand() ^ (rand() << 15);
volatile INT32 testi32a = rand() ^ (rand() << 15);
@ -395,10 +379,6 @@ void validity_checker::validate_inlines()
if (testu64a == 0) testu64a++;
if (testi64a == 0) testi64a++;
else if (testi64a < 0) testi64a = -testi64a;
#ifdef PTR64
if (testi64b == 0) testi64b++;
else if (testi64b < 0) testi64b = -testi64b;
#endif
if (testu32a == 0) testu32a++;
if (testu32b == 0) testu32b++;
if (testi32a == 0) testi32a++;

View File

@ -1497,11 +1497,11 @@ private:
// CORE FORMATTING FUNCTION
//**************************************************************************
template <typename Stream, typename Format>
typename Stream::off_type stream_format(Stream &str, Format const &args)
template <typename Stream, typename Base>
typename Stream::off_type stream_format(Stream &str, format_argument_pack<Base> const &args)
{
typedef format_helper<std::remove_cv_t<Format> > format_helper;
typedef typename Format::iterator iterator;
typedef format_helper<format_argument_pack<Base> > format_helper;
typedef typename format_argument_pack<Base>::iterator iterator;
class stream_preserver
{
public:
@ -1681,41 +1681,41 @@ inline String string_format(std::locale const &locale, Format &&fmt, Params &&..
return str.str();
};
template <typename String = std::string, typename Format, typename Stream>
inline String string_format(Format &&fmt, detail::format_argument_pack<Stream> const &args)
template <typename String = std::string, typename Stream>
inline String string_format(detail::format_argument_pack<Stream> const &args)
{
typedef std::basic_ostringstream<typename String::value_type, typename String::traits_type, typename String::allocator_type> ostream;
ostream str;
stream_format(str, std::forward<Format>(fmt), args);
detail::stream_format(str, args);
return str.str();
};
template <typename String = std::string, typename Format, typename Stream>
inline String string_format(Format &&fmt, detail::format_argument_pack<Stream> &&args)
template <typename String = std::string, typename Stream>
inline String string_format(detail::format_argument_pack<Stream> &&args)
{
typedef std::basic_ostringstream<typename String::value_type, typename String::traits_type, typename String::allocator_type> ostream;
ostream str;
stream_format(str, std::forward<Format>(fmt), std::move(args));
detail::stream_format(str, std::move(args));
return str.str();
};
template <typename String = std::string, typename Format, typename Stream>
inline String string_format(std::locale const &locale, Format &&fmt, detail::format_argument_pack<Stream> const &args)
template <typename String = std::string, typename Stream>
inline String string_format(std::locale const &locale, detail::format_argument_pack<Stream> const &args)
{
typedef std::basic_ostringstream<typename String::value_type, typename String::traits_type, typename String::allocator_type> ostream;
ostream str;
str.imbue(locale);
stream_format(str, std::forward<Format>(fmt), args);
detail::stream_format(str, args);
return str.str();
};
template <typename String = std::string, typename Format, typename Stream>
inline String string_format(std::locale const &locale, Format &&fmt, detail::format_argument_pack<Stream> &&args)
template <typename String = std::string, typename Stream>
inline String string_format(std::locale const &locale, detail::format_argument_pack<Stream> &&args)
{
typedef std::basic_ostringstream<typename String::value_type, typename String::traits_type, typename String::allocator_type> ostream;
ostream str;
str.imbue(locale);
stream_format(str, std::forward<Format>(fmt), std::move(args));
detail::stream_format(str, std::move(args));
return str.str();
};