Skip to content

Commit 964da01

Browse files
author
Hana Dusíková
committed
disable literals for MSVC
1 parent 7d951a4 commit 964da01

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

include/ctre/literals.hpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ template <typename CharT, CharT... input> static inline constexpr auto _fixed_st
2020

2121
namespace literals {
2222

23+
#ifndef _MSC_VER
24+
2325
// add this when we will have concepts
2426
// requires ctll::parser<ctre::pcre, _fixed_string_reference<CharT, charpack...>, ctre::pcre_actions>::template correct_with<pcre_context<>>
2527

2628
#if !__cpp_nontype_template_parameter_class
27-
template <typename CharT, CharT... charpack> __attribute__((flatten)) constexpr CTRE_FORCE_INLINE auto operator""_ctre() noexcept {
29+
template <typename CharT, CharT... charpack> CTRE_FLATTEN constexpr CTRE_FORCE_INLINE auto operator""_ctre() noexcept {
2830
constexpr auto & input = _fixed_string_reference<CharT, charpack...>;
2931
#else
30-
template <basic_fixed_string input> __attribute__((flatten)) constexpr CTRE_FORCE_INLINE auto operator""_ctre() noexcept {
32+
template <basic_fixed_string input> CTRE_FLATTEN constexpr CTRE_FORCE_INLINE auto operator""_ctre() noexcept {
3133
#endif
3234
using tmp = typename ctll::parser<ctre::pcre, input, ctre::pcre_actions>::template output<pcre_context<>>;
3335
static_assert(tmp(), "Regular Expression contains syntax error.");
@@ -38,28 +40,32 @@ template <basic_fixed_string input> __attribute__((flatten)) constexpr CTRE_FORC
3840

3941

4042
// this will need to be fixed with C++20
41-
template <typename CharT, CharT... charpack> __attribute__((flatten)) constexpr CTRE_FORCE_INLINE auto operator""_ctre_id() noexcept {
43+
template <typename CharT, CharT... charpack> CTRE_FLATTEN constexpr CTRE_FORCE_INLINE auto operator""_ctre_id() noexcept {
4244
return id<charpack...>();
4345
}
4446

47+
#endif
48+
4549
}
4650

4751
namespace test_literals {
52+
53+
#ifndef _MSC_VER
4854

4955
#if !__cpp_nontype_template_parameter_class
50-
template <typename CharT, CharT... charpack> __attribute__((flatten)) constexpr inline auto operator""_ctre_test() noexcept {
56+
template <typename CharT, CharT... charpack> CTRE_FLATTEN constexpr inline auto operator""_ctre_test() noexcept {
5157
constexpr auto & input = _fixed_string_reference<CharT, charpack...>;
5258
#else
53-
template <basic_fixed_string input> __attribute__((flatten)) constexpr inline auto operator""_ctre_test() noexcept {
59+
template <basic_fixed_string input> CTRE_FLATTEN constexpr inline auto operator""_ctre_test() noexcept {
5460
#endif
5561
return ctll::parser<ctre::pcre, input>::correct;
5662
}
5763

5864
#if !__cpp_nontype_template_parameter_class
59-
template <typename CharT, CharT... charpack> __attribute__((flatten)) constexpr inline auto operator""_ctre_gen() noexcept {
65+
template <typename CharT, CharT... charpack> CTRE_FLATTEN constexpr inline auto operator""_ctre_gen() noexcept {
6066
constexpr auto & input = _fixed_string_reference<CharT, charpack...>;
6167
#else
62-
template <basic_fixed_string input> __attribute__((flatten)) constexpr inline auto operator""_ctre_gen() noexcept {
68+
template <basic_fixed_string input> CTRE_FLATTEN constexpr inline auto operator""_ctre_gen() noexcept {
6369
#endif
6470
using tmp = typename ctll::parser<ctre::pcre, input, ctre::pcre_actions>::template output<pcre_context<>>;
6571
static_assert(tmp(), "Regular Expression contains syntax error.");
@@ -68,24 +74,26 @@ template <basic_fixed_string input> __attribute__((flatten)) constexpr inline au
6874

6975

7076
#if !__cpp_nontype_template_parameter_class
71-
template <typename CharT, CharT... charpack> __attribute__((flatten)) constexpr CTRE_FORCE_INLINE auto operator""_ctre_syntax() noexcept {
77+
template <typename CharT, CharT... charpack> CTRE_FLATTEN constexpr CTRE_FORCE_INLINE auto operator""_ctre_syntax() noexcept {
7278
constexpr auto & input = _fixed_string_reference<CharT, charpack...>;
7379
#else
74-
template <basic_fixed_string input> __attribute__((flatten)) constexpr CTRE_FORCE_INLINE auto operator""_ctre_syntax() noexcept {
80+
template <basic_fixed_string input> CTRE_FLATTEN constexpr CTRE_FORCE_INLINE auto operator""_ctre_syntax() noexcept {
7581
#endif
7682
return ctll::parser<ctre::pcre, input, ctre::pcre_actions>::template correct_with<pcre_context<>>;
7783
}
7884

7985

8086
#if !__cpp_nontype_template_parameter_class
81-
template <typename CharT, CharT... charpack> __attribute__((flatten)) constexpr inline auto operator""_simple_test() noexcept {
87+
template <typename CharT, CharT... charpack> CTRE_FLATTEN constexpr inline auto operator""_simple_test() noexcept {
8288
constexpr auto & input = _fixed_string_reference<CharT, charpack...>;
8389
#else
84-
template <basic_fixed_string input> __attribute__((flatten)) constexpr inline auto operator""_simple_test() noexcept {
90+
template <basic_fixed_string input> CTRE_FLATTEN constexpr inline auto operator""_simple_test() noexcept {
8591
#endif
8692
return ctll::parser<ctre::simple, input>::correct;
8793
}
8894

95+
#endif
96+
8997

9098
} // literals
9199

0 commit comments

Comments
 (0)