Skip to content

Commit

Permalink
Merge 3d8aa79 into 250d501
Browse files Browse the repository at this point in the history
  • Loading branch information
Giperion committed Dec 9, 2017
2 parents 250d501 + 3d8aa79 commit 3e1f54f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
17 changes: 15 additions & 2 deletions include/boost/pfr/detail/config.hpp
Expand Up @@ -12,10 +12,24 @@
// * MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
// * MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)

//for MSVC warning and error message
#ifdef _MSC_VER
#define Stringize( L ) #L
#define MakeString( M, L ) M(L)
#define $Line MakeString( Stringize, __LINE__ )
#define MSVC_Warning __FILE__ "(" $Line ") : warning: "
#define MSVC_Error __FILE__ "(" $Line ") : error: "
#endif

//MSVC store C++ version in _MSVC_LANG macro, not in __cplusplus

#if defined(_MSC_VER)
# if _MSC_VER <= 1900
# error Boost.PFR library requires MSVC with c++17 support (Visual Studio 2017 or later).
# pragma message(MSVC_Warning "Boost.PFR library requires MSVC with c++17 support (Visual Studio 2017 or later).")
# endif
# if _MSVC_LANG < 201703L
# pragma message(MSVC_Error "PFR library supports MSVC compiler only with /std:c++latest or /std:c++17 flag. Go to Project properties -> C/C++ -> Language -> C++ Language Standart")
# endif
#elif __cplusplus < 201402L
# error Boost.PFR library requires at least C++14.
#endif
Expand All @@ -28,7 +42,6 @@
# ifdef __cpp_structured_bindings
# define BOOST_PFR_USE_CPP17 1
# elif defined(_MSC_VER)
# warning PFR library supports MSVC compiler only with /std:c++latest or /std:c++17 flag. Assuming that you`ve used it. Define `BOOST_PFR_USE_CPP17` to 1 to suppress this warning.
# define BOOST_PFR_USE_CPP17 1
# else
# define BOOST_PFR_USE_CPP17 0
Expand Down
16 changes: 13 additions & 3 deletions include/boost/pfr/flat/tuple_size.hpp
Expand Up @@ -14,17 +14,27 @@
#include <boost/pfr/detail/sequence_tuple.hpp>
#include <boost/pfr/detail/core14.hpp>

//for flat_tuple_size, see below
#ifdef _MSC_VER
constexpr std::size_t size_v = 4;
#endif

namespace boost { namespace pfr {

/// \brief Has a static const member variable `value` that contains fields count in a \flattening{flattened} T.
///
/// \note (Giperion): On MSVC not working properly (compiler not support correctly)
/// \b Example:
/// \code
/// std::array<int, boost::pfr::flat_tuple_size<my_structure>::value > a;
/// \endcode
template <class T>
using flat_tuple_size = boost::pfr::detail::size_t_<decltype(boost::pfr::detail::tie_as_flat_tuple(std::declval<T&>()))::size_v>;

#ifdef _MSC_VER
template <class T>
using flat_tuple_size = boost::pfr::detail::size_t_<size_v>;
#else
template <class T>
using flat_tuple_size = boost::pfr::detail::size_t_<decltype(boost::pfr::detail::tie_as_flat_tuple(std::declval<T&>()))::size_v>;
#endif

/// \brief `flat_tuple_size_v` is a template variable that contains fields count in a \flattening{flattened} T.
///
Expand Down

0 comments on commit 3e1f54f

Please sign in to comment.