add _tail placeholders User-defined Literals

This commit is contained in:
bolero-MURAKAMI 2013-07-09 01:37:01 +09:00
parent 8fa8d80ca2
commit 651d8deba8
2 changed files with 20 additions and 4 deletions

View file

@ -200,7 +200,7 @@ namespace sprout {
: public std::integral_constant<
bool,
(sprout::is_placeholder<typename sprout::tuples::tuple_element<sprout::tuples::tuple_size<Bounds>::value - 1, Bounds>::type>::value
<= -256
<= sprout::is_placeholder<decltype(sprout::placeholders::_va)>::value
)
>
{};
@ -216,7 +216,7 @@ namespace sprout {
>
: public std::integral_constant<
int,
(-256
(sprout::is_placeholder<decltype(sprout::placeholders::_va)>::value
- sprout::is_placeholder<typename sprout::tuples::tuple_element<sprout::tuples::tuple_size<Bounds>::value - 1, Bounds>::type>::value
)
>
@ -627,7 +627,7 @@ namespace sprout {
template<sprout::index_t Index, typename BoundArg>
struct complete_placeholder<
Index, BoundArg,
typename std::enable_if<!(sprout::is_placeholder<BoundArg>::value == -1)>::type
typename std::enable_if<!(sprout::is_placeholder<BoundArg>::value == sprout::is_placeholder<decltype(sprout::placeholders::_)>::value)>::type
> {
public:
typedef BoundArg type;
@ -635,7 +635,7 @@ namespace sprout {
template<sprout::index_t Index, typename BoundArg>
struct complete_placeholder<
Index, BoundArg,
typename std::enable_if<(sprout::is_placeholder<BoundArg>::value == -1)>::type
typename std::enable_if<(sprout::is_placeholder<BoundArg>::value == sprout::is_placeholder<decltype(sprout::placeholders::_)>::value)>::type
> {
public:
typedef sprout::placeholder<Index + 1> type;

View file

@ -12,6 +12,7 @@
namespace sprout {
//
// placeholders_result
// variadic_placeholders_result
//
template<char... Chars>
struct placeholders_result
@ -19,11 +20,18 @@ namespace sprout {
sprout::placeholder<sprout::detail::digits_to_int<int, Chars...>::value>
>
{};
template<char... Chars>
struct variadic_placeholders_result
: public sprout::identity<
sprout::placeholder<sprout::is_placeholder<decltype(sprout::placeholders::_va)>::value - sprout::detail::digits_to_int<int, Chars...>::value>
>
{};
namespace placeholders {
namespace udl {
//
// _
// _tail
//
template<char... Chars>
SPROUT_CONSTEXPR typename sprout::placeholders_result<Chars...>::type
@ -31,15 +39,23 @@ namespace sprout {
typedef typename sprout::placeholders_result<Chars...>::type type;
return type();
}
template<char... Chars>
SPROUT_CONSTEXPR typename sprout::variadic_placeholders_result<Chars...>::type
operator"" _tail() {
typedef typename sprout::variadic_placeholders_result<Chars...>::type type;
return type();
}
} // namespace udl
} // namespace placeholders
namespace udl {
namespace placeholders {
using sprout::placeholders::udl::operator"" _;
using sprout::placeholders::udl::operator"" _tail;
} // namespace placeholders
using sprout::placeholders::udl::operator"" _;
using sprout::placeholders::udl::operator"" _tail;
} // namespace udl
} // namespace sprout