mirror of
https://github.com/boostorg/typeof.git
synced 2025-12-25 08:18:29 +01:00
Compare commits
9 Commits
boost-1.66
...
feature/pu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f7843999c | ||
|
|
db3537ad7b | ||
|
|
cb9dd92bba | ||
|
|
79232ea172 | ||
|
|
727da87e70 | ||
|
|
37e1265b39 | ||
|
|
f16777e743 | ||
|
|
0047815f4a | ||
|
|
5d737d61e5 |
@@ -10,8 +10,10 @@
|
||||
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
#ifndef BOOST_NO_CXX98_FUNCTION_BASE
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(std::unary_function, 2)
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(std::binary_function, 3)
|
||||
#endif//BOOST_NO_CXX98_FUNCTION_BASE
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(std::plus, 1)
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(std::minus, 1)
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(std::multiplies, 1)
|
||||
@@ -30,6 +32,8 @@ BOOST_TYPEOF_REGISTER_TEMPLATE(std::logical_not, 1)
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(std::unary_negate, 1)
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(std::binary_negate, 1)
|
||||
|
||||
#ifndef BOOST_NO_CXX98_BINDERS
|
||||
|
||||
#if defined(__MWERKS__) && defined(_MSL_EXTENDED_BINDERS)
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(std::binder1st, 2)
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(std::binder2nd, 2)
|
||||
@@ -52,4 +56,6 @@ BOOST_TYPEOF_REGISTER_TEMPLATE(std::mem_fun1_ref_t, 3)
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(std::const_mem_fun1_ref_t, 3)
|
||||
#endif//BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, == 1)
|
||||
|
||||
#endif//BOOST_NO_CXX98_BINDERS
|
||||
|
||||
#endif//BOOST_TYPEOF_STD_functional_hpp_INCLUDED
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(std::allocator, 1)
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(std::raw_storage_iterator, 2)
|
||||
#ifndef BOOST_NO_AUTO_PTR
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(std::auto_ptr, 1)
|
||||
#endif//BOOST_NO_AUTO_PTR
|
||||
|
||||
#endif//BOOST_TYPEOF_STD_memory_hpp_INCLUDED
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && !defined(BOOST_TYPEOF_EMULATION)
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1900) && !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) && !defined(BOOST_TYPEOF_EMULATION)
|
||||
# define BOOST_TYPEOF_DECLTYPE
|
||||
# ifndef BOOST_TYPEOF_NATIVE
|
||||
# define BOOST_TYPEOF_NATIVE
|
||||
|
||||
74
test/msvc_typeof_in_lambda.cpp
Normal file
74
test/msvc_typeof_in_lambda.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
// Copyright (C) 2018 Tobias Loew
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_LAMBDAS)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test due to BOOST_NO_CXX11_LAMBDAS")
|
||||
int main() {}
|
||||
|
||||
#elif defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test due to BOOST_NO_CXX11_AUTO_DECLARATIONS")
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/typeof/typeof.hpp>
|
||||
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
|
||||
|
||||
namespace detail {
|
||||
template<class T> inline T& deref(T& r) {
|
||||
return r;
|
||||
}
|
||||
template<class T>
|
||||
struct wrapper {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T> wrapper<T> wrap(T&);
|
||||
};
|
||||
|
||||
BOOST_TYPEOF_REGISTER_TEMPLATE(::detail::wrapper, 1)
|
||||
|
||||
void test_typeof_in_lambda() {
|
||||
// Visual Studio 2015 (BOOST_MSVC == 1900) had an internal compiler error with Boost 1.65 and 1.66 when using BOOST_SCOPE_EXIT inside a lambda
|
||||
// the error was due to a change of include in boost/typeof/typeof.hpp (<boost/typeof/decltype.hpp> instead of <boost/typeof/native.hpp>)
|
||||
// This test is an more or less minimal extract from the BOOST_SCOPE_EXIT macro expansions
|
||||
|
||||
// worked also with VS 2015 in version 1.65/1.66
|
||||
int n;
|
||||
typedef BOOST_TYPEOF(::detail::wrap(::detail::deref(n))) n_type_wrapped;
|
||||
typedef n_type_wrapped::type n_type;
|
||||
|
||||
int test;
|
||||
|
||||
auto check_property = [&n,&test]() {
|
||||
// internal compiler error with VS 2015 in version 1.65/1.66
|
||||
// minimal extract from
|
||||
//BOOST_SCOPE_EXIT(test) {
|
||||
// test = 42;
|
||||
//}BOOST_SCOPE_EXIT_END
|
||||
|
||||
// this compiles always (as long as the one before outside the lambda has the same name)
|
||||
typedef BOOST_TYPEOF(::detail::wrap(::detail::deref(n))) n_type_wrapped;
|
||||
typedef n_type_wrapped::type n_type;
|
||||
|
||||
// this fails with internal compiler error with VS 2015 in version 1.65/1.66
|
||||
typedef BOOST_TYPEOF(::detail::wrap(::detail::deref(test))) test_type_wrapped;
|
||||
typedef test_type_wrapped::type test_type;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
test_typeof_in_lambda();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -42,8 +42,10 @@ BOOST_STATIC_ASSERT(boost::type_of::test<bitset<10> >::value);
|
||||
|
||||
// function objects
|
||||
|
||||
#ifndef BOOST_NO_CXX98_FUNCTION_BASE
|
||||
BOOST_STATIC_ASSERT((boost::type_of::test<unary_function<int, int> >::value));
|
||||
BOOST_STATIC_ASSERT((boost::type_of::test<binary_function<int, int, int> >::value));
|
||||
#endif//BOOST_NO_CXX98_FUNCTION_BASE
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<plus<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<minus<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<multiplies<int> >::value);
|
||||
@@ -61,8 +63,10 @@ BOOST_STATIC_ASSERT(boost::type_of::test<logical_or<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<logical_not<int> >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<unary_negate<negate<int> > >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<binary_negate<less<int> > >::value);
|
||||
#ifndef BOOST_NO_CXX98_BINDERS
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<binder1st<less<int> > >::value);
|
||||
BOOST_STATIC_ASSERT(boost::type_of::test<binder2nd<less<int> > >::value);
|
||||
#endif//BOOST_NO_CXX98_BINDERS
|
||||
|
||||
// valarray
|
||||
|
||||
|
||||
Reference in New Issue
Block a user