Skip to content

Commit

Permalink
Merge pull request #320 from bluescarni/pr/msvc_fixes
Browse files Browse the repository at this point in the history
MSVC fixes
  • Loading branch information
bluescarni authored Dec 5, 2024
2 parents 588b96a + ad48377 commit e8d63ca
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 54 deletions.
10 changes: 0 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,6 @@ if(YACMA_COMPILER_IS_MSVC)
list(APPEND MPPP_CXX_FLAGS_DEBUG "/wd4459" "/wd4127")
list(APPEND MPPP_CXX_FLAGS_RELEASE "/wd4459" "/wd4127")
endif()
# Enable strict conformance mode, if supported.
set(CMAKE_REQUIRED_QUIET TRUE)
check_cxx_compiler_flag("/permissive-" _MPPP_MSVC_SUPPORTS_STRICT_CONFORMANCE)
unset(CMAKE_REQUIRED_QUIET)
if(_MPPP_MSVC_SUPPORTS_STRICT_CONFORMANCE)
message(STATUS "The '/permissive-' flag is supported, enabling it.")
list(APPEND MPPP_CXX_FLAGS_DEBUG "/permissive-")
list(APPEND MPPP_CXX_FLAGS_RELEASE "/permissive-")
endif()
unset(_MPPP_MSVC_SUPPORTS_STRICT_CONFORMANCE)
endif()
if(YACMA_COMPILER_IS_INTELXX)
# NOTE: on MSVC we use the push/pop pragmas, but they do not seem to work on Intel (the pragmas
Expand Down
4 changes: 4 additions & 0 deletions cmake/yacma/YACMACompilerLinkerSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ if(NOT _YACMACompilerLinkerSettingsRun)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(/W4)
# Treat warnings as errors.
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(/WX)
# Strict conformance mode.
_YACMA_CHECK_ENABLE_CXX_FLAG(/permissive-)
# Strict preprocessor conformance mode.
_YACMA_CHECK_ENABLE_CXX_FLAG(/Zc:preprocessor)
endif()

# Set the cache variables.
Expand Down
32 changes: 21 additions & 11 deletions include/mp++/complex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3161,19 +3161,29 @@ inline bool operator!=(const T &x, const U &y)
inline namespace literals
{

#define MPPP_DECLARE_COMPLEX_UDL(prec) \
template <char... Chars> \
inline complex operator""_icr##prec() \
{ \
return complex{real{real_kind::zero, prec}, detail::real_literal_impl<Chars...>(prec)}; \
}
template <char... Chars>
inline complex operator""_icr128()
{
return complex{real{real_kind::zero, 128}, detail::real_literal_impl<Chars...>(128)};
}

MPPP_DECLARE_COMPLEX_UDL(128)
MPPP_DECLARE_COMPLEX_UDL(256)
MPPP_DECLARE_COMPLEX_UDL(512)
MPPP_DECLARE_COMPLEX_UDL(1024)
template <char... Chars>
inline complex operator""_icr256()
{
return complex{real{real_kind::zero, 256}, detail::real_literal_impl<Chars...>(256)};
}

#undef MPPP_DECLARE_COMPLEX_UDL
template <char... Chars>
inline complex operator""_icr512()
{
return complex{real{real_kind::zero, 512}, detail::real_literal_impl<Chars...>(512)};
}

template <char... Chars>
inline complex operator""_icr1024()
{
return complex{real{real_kind::zero, 1024}, detail::real_literal_impl<Chars...>(1024)};
}

} // namespace literals

Expand Down
25 changes: 15 additions & 10 deletions include/mp++/detail/integer_literals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,18 +400,23 @@ inline integer<SSize> integer_literal_impl()
inline namespace literals
{

#define MPPP_DECLARE_INTEGRAL_UDL(n) \
template <char... Chars> \
inline integer<n> operator""_z##n() \
{ \
return detail::integer_literal_impl<n, Chars...>(); \
}
template <char... Chars>
inline integer<1> operator""_z1()
{
return detail::integer_literal_impl<1, Chars...>();
}

MPPP_DECLARE_INTEGRAL_UDL(1)
MPPP_DECLARE_INTEGRAL_UDL(2)
MPPP_DECLARE_INTEGRAL_UDL(3)
template <char... Chars>
inline integer<2> operator""_z2()
{
return detail::integer_literal_impl<2, Chars...>();
}

#undef MPPP_DECLARE_INTEGRAL_UDL
template <char... Chars>
inline integer<3> operator""_z3()
{
return detail::integer_literal_impl<3, Chars...>();
}

} // namespace literals

Expand Down
28 changes: 16 additions & 12 deletions include/mp++/detail/rational_literals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,22 @@ MPPP_BEGIN_NAMESPACE
inline namespace literals
{

#define MPPP_DECLARE_RATIONAL_UDL(n) \
template <char... Chars> \
inline rational<n> operator""_q##n() \
{ \
return rational<n>{detail::integer_literal_impl<n, Chars...>()}; \
}

MPPP_DECLARE_RATIONAL_UDL(1)
MPPP_DECLARE_RATIONAL_UDL(2)
MPPP_DECLARE_RATIONAL_UDL(3)

#undef MPPP_DECLARE_RATIONAL_UDL
template <char... Chars>
inline rational<1> operator""_q1()
{
return rational<1>{detail::integer_literal_impl<1, Chars...>()};
}
template <char... Chars>
inline rational<2> operator""_q2()
{
return rational<2>{detail::integer_literal_impl<2, Chars...>()};
}

template <char... Chars>
inline rational<3> operator""_q3()
{
return rational<3>{detail::integer_literal_impl<3, Chars...>()};
}

} // namespace literals

Expand Down
32 changes: 21 additions & 11 deletions include/mp++/detail/real_literals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,29 @@ inline real real_literal_impl(::mpfr_prec_t prec)
inline namespace literals
{

#define MPPP_DECLARE_REAL_UDL(prec) \
template <char... Chars> \
inline real operator""_r##prec() \
{ \
return detail::real_literal_impl<Chars...>(prec); \
}
template <char... Chars>
inline real operator""_r128()
{
return detail::real_literal_impl<Chars...>(128);
}

template <char... Chars>
inline real operator""_r256()
{
return detail::real_literal_impl<Chars...>(256);
}

MPPP_DECLARE_REAL_UDL(128)
MPPP_DECLARE_REAL_UDL(256)
MPPP_DECLARE_REAL_UDL(512)
MPPP_DECLARE_REAL_UDL(1024)
template <char... Chars>
inline real operator""_r512()
{
return detail::real_literal_impl<Chars...>(512);
}

#undef MPPP_DECLARE_REAL_UDL
template <char... Chars>
inline real operator""_r1024()
{
return detail::real_literal_impl<Chars...>(1024);
}

} // namespace literals

Expand Down

0 comments on commit e8d63ca

Please sign in to comment.