diff --git a/sprout/preprocessor/config.hpp b/sprout/preprocessor/config.hpp index abda9661..5dbf0af6 100644 --- a/sprout/preprocessor/config.hpp +++ b/sprout/preprocessor/config.hpp @@ -43,4 +43,15 @@ # define SPROUT_PP_VARIADICS 0 #endif +// +// SPROUT_PP_HAS_COUNTER +// +#ifdef __COUNTER__ +# undef SPROUT_PP_HAS_COUNTER +# define SPROUT_PP_HAS_COUNTER 1 +#else +# undef SPROUT_PP_HAS_COUNTER +# define SPROUT_PP_HAS_COUNTER 0 +#endif + #endif // #ifndef SPROUT_PREPROCESSOR_CONFIG_HPP diff --git a/sprout/preprocessor/some_number.hpp b/sprout/preprocessor/some_number.hpp index 3e5fe0bb..b0425c9e 100644 --- a/sprout/preprocessor/some_number.hpp +++ b/sprout/preprocessor/some_number.hpp @@ -9,13 +9,25 @@ #define SPROUT_PREPROCESSOR_SOME_NUMBER_HPP #include +#include #include +// +// SPROUT_PP_SOME_NUMBER_IS_UNIQUE_IN_LINE +// +#if SPROUT_PP_HAS_COUNTER +# undef SPROUT_PP_SOME_NUMBER_IS_UNIQUE_IN_LINE +# define SPROUT_PP_SOME_NUMBER_IS_UNIQUE_IN_LINE 1 +#else +# undef SPROUT_PP_SOME_NUMBER_IS_UNIQUE_IN_LINE +# define SPROUT_PP_SOME_NUMBER_IS_UNIQUE_IN_LINE 0 +#endif + // // SPROUT_PP_SOME_NUMBER // SPROUT_PP_SOME_NUMBER_OR_EMPTY // -#ifdef __COUNTER__ +#if SPROUT_PP_HAS_COUNTER # define SPROUT_PP_SOME_NUMBER() __COUNTER__ # define SPROUT_PP_SOME_NUMBER_OR_EMPTY() SPROUT_PP_SOME_NUMBER() #else diff --git a/sprout/preprocessor/str.hpp b/sprout/preprocessor/str.hpp new file mode 100644 index 00000000..0b659864 --- /dev/null +++ b/sprout/preprocessor/str.hpp @@ -0,0 +1,18 @@ +/*============================================================================= + Copyright (c) 2011-2016 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_PREPROCESSOR_STR_HPP +#define SPROUT_PREPROCESSOR_STR_HPP + +#include + +// +// SPROUT_PP_STR +// +#define SPROUT_PP_STR(str) str + +#endif // #ifndef SPROUT_PREPROCESSOR_STR_HPP diff --git a/sprout/preprocessor/str_all.hpp b/sprout/preprocessor/str_all.hpp index f86ce43c..ab58b67e 100644 --- a/sprout/preprocessor/str_all.hpp +++ b/sprout/preprocessor/str_all.hpp @@ -9,6 +9,7 @@ #define SPROUT_PREPROCESSOR_STR_ALL_HPP #include +#include #include #include #include diff --git a/sprout/preprocessor/unique_string.hpp b/sprout/preprocessor/unique_string.hpp index 341ce7f5..14305ea8 100644 --- a/sprout/preprocessor/unique_string.hpp +++ b/sprout/preprocessor/unique_string.hpp @@ -13,6 +13,29 @@ #include #include +// +// SPROUT_PP_UNIQUE_STRING_ +// SPROUT_PP_UNIQUE_WSTRING_ +// SPROUT_PP_UNIQUE_U16STRING_ +// SPROUT_PP_UNIQUE_U32STRING_ +// +#define SPROUT_PP_UNIQUE_STRING_(N) \ + SPROUT_PP_STRINGIZE(N) SPROUT_PP_STR(" ") \ + SPROUT_PP_STR(__DATE__) SPROUT_PP_STR(" ") SPROUT_PP_STR(__TIME__) \ + SPROUT_PP_STR(" : ") SPROUT_PP_STR(__FILE__) SPROUT_PP_STR(":") SPROUT_PP_STRINGIZE(__LINE__) +#define SPROUT_PP_UNIQUE_WSTRING_(N) \ + SPROUT_PP_WSTRINGIZE(N) SPROUT_PP_WSTR(" ") \ + SPROUT_PP_WSTR(__DATE__) SPROUT_PP_WSTR(" ") SPROUT_PP_WSTR(__TIME__) \ + SPROUT_PP_WSTR(" : ") SPROUT_PP_WSTR(__FILE__) SPROUT_PP_WSTR(":") SPROUT_PP_WSTRINGIZE(__LINE__) +#define SPROUT_PP_UNIQUE_U16STRING_(N) \ + SPROUT_PP_U16STRINGIZE(N) SPROUT_PP_U16STR(" ") \ + SPROUT_PP_U16STR(__DATE__) SPROUT_PP_U16STR(" ") SPROUT_PP_U16STR(__TIME__) \ + SPROUT_PP_U16STR(" : ") SPROUT_PP_U16STR(__FILE__) SPROUT_PP_U16STR(":") SPROUT_PP_U16STRINGIZE(__LINE__) +#define SPROUT_PP_UNIQUE_U32STRING_(N) \ + SPROUT_PP_U32STRINGIZE(N) SPROUT_PP_U32STR(" ") \ + SPROUT_PP_U32STR(__DATE__) SPROUT_PP_U32STR(" ") SPROUT_PP_U32STR(__TIME__) \ + SPROUT_PP_U32STR(" : ") SPROUT_PP_U32STR(__FILE__) SPROUT_PP_U32STR(":") SPROUT_PP_U32STRINGIZE(__LINE__) + // // SPROUT_PP_UNIQUE_STRING // SPROUT_PP_UNIQUE_WSTRING @@ -20,20 +43,12 @@ // SPROUT_PP_UNIQUE_U32STRING // #define SPROUT_PP_UNIQUE_STRING \ - SPROUT_PP_STRINGIZE(SPROUT_PP_SOME_NUMBER()) " " \ - __DATE__ " " __TIME__ \ - " : " __FILE__ ":" SPROUT_PP_STRINGIZE(__LINE__) + SPROUT_PP_UNIQUE_STRING_(SPROUT_PP_SOME_NUMBER()) #define SPROUT_PP_UNIQUE_WSTRING \ - SPROUT_PP_WSTRINGIZE(SPROUT_PP_SOME_NUMBER()) SPROUT_PP_WSTR(" ") \ - SPROUT_PP_WSTR(__DATE__) SPROUT_PP_WSTR(" ") SPROUT_PP_WSTR(__TIME__) \ - SPROUT_PP_WSTR(" : ") SPROUT_PP_WSTR(__FILE__) SPROUT_PP_WSTR(":") SPROUT_PP_WSTRINGIZE(__LINE__) + SPROUT_PP_UNIQUE_WSTRING_(SPROUT_PP_SOME_NUMBER()) #define SPROUT_PP_UNIQUE_U16STRING \ - SPROUT_PP_U16STRINGIZE(SPROUT_PP_SOME_NUMBER()) SPROUT_PP_U16STR(" ") \ - SPROUT_PP_U16STR(__DATE__) SPROUT_PP_U16STR(" ") SPROUT_PP_U16STR(__TIME__) \ - SPROUT_PP_U16STR(" : ") SPROUT_PP_U16STR(__FILE__) SPROUT_PP_U16STR(":") SPROUT_PP_U16STRINGIZE(__LINE__) + SPROUT_PP_UNIQUE_U16STRING_(SPROUT_PP_SOME_NUMBER()) #define SPROUT_PP_UNIQUE_U32STRING \ - SPROUT_PP_U32STRINGIZE(SPROUT_PP_SOME_NUMBER()) SPROUT_PP_U32STR(" ") \ - SPROUT_PP_U32STR(__DATE__) SPROUT_PP_U32STR(" ") SPROUT_PP_U32STR(__TIME__) \ - SPROUT_PP_U32STR(" : ") SPROUT_PP_U32STR(__FILE__) SPROUT_PP_U32STR(":") SPROUT_PP_U32STRINGIZE(__LINE__) + SPROUT_PP_UNIQUE_U32STRING_(SPROUT_PP_SOME_NUMBER()) #endif // #ifndef SPROUT_PREPROCESSOR_UNIQUE_STRING_HPP diff --git a/sprout/random/unique_seed.hpp b/sprout/random/unique_seed.hpp index 0768f411..1fa533ec 100644 --- a/sprout/random/unique_seed.hpp +++ b/sprout/random/unique_seed.hpp @@ -54,10 +54,17 @@ namespace sprout { } } // namespace sprout +// +// SPROUT_UNIQUE_SEED_ +// +#define SPROUT_UNIQUE_SEED_(N) \ + (::sprout::make_seed(SPROUT_PP_UNIQUE_STRING_(N))) + // // SPROUT_UNIQUE_SEED // -#define SPROUT_UNIQUE_SEED (::sprout::make_seed(SPROUT_PP_UNIQUE_STRING)) +#define SPROUT_UNIQUE_SEED \ + (::sprout::make_seed(SPROUT_PP_UNIQUE_STRING)) // // SPROUT_UNIQUE_SEED_SEQ