Skip to content

Instantly share code, notes, and snippets.

template <size_t ...values>
struct values_container
{};
template <typename container>
struct starts_with_123
{
static constexpr bool value = ...;
}
template <typename>
struct starts_with_123_impl;
template <size_t ...values>
struct starts_with_123_impl<values_container<values...>>
{};
template <size_t ...rest_of_values>
struct starts_with_123_impl<values_container<1, 2, 3, rest_of_values...>>
{};
template <size_t ...rest_of_values>
struct starts_with_123_impl<values_container<1, 2, 3, rest_of_values...>>
{
static constexpr bool value = true;
};
template <size_t ...values>
struct starts_with_123_impl<values_container<values...>>
{
static constexpr bool value = false;
template <typename container>
constexpr auto starts_with_123 = starts_with_123_impl<container>::value;
namespace details
{
template <typename>
struct starts_with_123_impl;
template <size_t ...values>
struct starts_with_123_impl<values_container<1, 2, 3, values...>>
{
static constexpr bool value = true;
};
template <char ...chars>
struct string
{
static constexpr auto size = sizeof...(chars);
};
namespace details
{
template <typename str>
struct to_string_impl;
template <char ...chars>
struct to_string_impl<string<chars...>>
{
using type = string<chars...>;
};