diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..eb1a81c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,327 @@ +# Copyright 2016, 2017 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) + +language: cpp + +sudo: false + +python: "2.7" + +os: + - linux + - osx + +branches: + only: + - master + - develop + +env: + matrix: + - BOGUS_JOB=true + +matrix: + + exclude: + - env: BOGUS_JOB=true + + include: + - os: linux + env: TOOLSET=gcc COMPILER=g++ CXXSTD=c++03 + + - os: linux + env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=c++03 + addons: + apt: + packages: + - g++-4.7 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=c++11 + addons: + apt: + packages: + - g++-4.7 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=c++03 + addons: + apt: + packages: + - g++-4.8 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=c++11 + addons: + apt: + packages: + - g++-4.8 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++03 + addons: + apt: + packages: + - g++-4.9 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++11 + addons: + apt: + packages: + - g++-4.9 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++03 + addons: + apt: + packages: + - g++-5 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++11 + addons: + apt: + packages: + - g++-5 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++14 + addons: + apt: + packages: + - g++-5 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++03 + addons: + apt: + packages: + - g++-6 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++11 + addons: + apt: + packages: + - g++-6 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++14 + addons: + apt: + packages: + - g++-6 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++1z + addons: + apt: + packages: + - g++-6 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++03 + + - os: linux + env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=c++03 + addons: + apt: + packages: + - clang-3.5 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.5 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=c++11 + addons: + apt: + packages: + - clang-3.5 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.5 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++03 + addons: + apt: + packages: + - clang-3.6 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.6 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++11 + addons: + apt: + packages: + - clang-3.6 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.6 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++03 + addons: + apt: + packages: + - clang-3.7 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.7 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++11 + addons: + apt: + packages: + - clang-3.7 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.7 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++03 + addons: + apt: + packages: + - clang-3.8 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.8 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++11 + addons: + apt: + packages: + - clang-3.8 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.8 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++14 + addons: + apt: + packages: + - clang-3.8 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.8 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++1z + addons: + apt: + packages: + - clang-3.8 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.8 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++03 + addons: + apt: + packages: + - clang-3.9 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.9 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++11 + addons: + apt: + packages: + - clang-3.9 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.9 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++14 + addons: + apt: + packages: + - clang-3.9 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.9 + + - os: linux + env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++1z + addons: + apt: + packages: + - clang-3.9 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.9 + + - os: osx + env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++03 + + - os: osx + env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11 + + - os: osx + env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++14 + + - os: osx + env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++1z + +install: + - cd .. + - git clone -b $TRAVIS_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + - cd boost-root + - git submodule update --init tools/build + - git submodule update --init libs/config + - git submodule update --init tools/boostdep + - cp -r $TRAVIS_BUILD_DIR/* libs/typeof + - python tools/boostdep/depinst/depinst.py typeof + - ./bootstrap.sh + - ./b2 headers + +script: + - |- + echo "using $TOOLSET : : $COMPILER : -std=$CXXSTD ;" > ~/user-config.jam + - ./b2 libs/typeof/test toolset=$TOOLSET + +notifications: + email: + on_success: always diff --git a/include/boost/typeof/decltype.hpp b/include/boost/typeof/decltype.hpp new file mode 100644 index 0000000..7e990a8 --- /dev/null +++ b/include/boost/typeof/decltype.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2006 Arkadiy Vertleyb +// Copyright (C) 2017 Daniela Engert +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_TYPEOF_DECLTYPE_HPP_INCLUDED +# define BOOST_TYPEOF_DECLTYPE_HPP_INCLUDED + +#include +#include + +namespace boost { namespace type_of { + template + using remove_cv_ref_t = typename remove_cv::type>::type; +}} + +#define BOOST_TYPEOF(expr) boost::type_of::remove_cv_ref_t +#define BOOST_TYPEOF_TPL BOOST_TYPEOF + +#define BOOST_TYPEOF_NESTED_TYPEDEF_TPL(name,expr) \ + struct name {\ + typedef BOOST_TYPEOF_TPL(expr) type;\ + }; + +#define BOOST_TYPEOF_NESTED_TYPEDEF(name,expr) \ + struct name {\ + typedef BOOST_TYPEOF(expr) type;\ + }; + +#define BOOST_TYPEOF_REGISTER_TYPE(x) +#define BOOST_TYPEOF_REGISTER_TEMPLATE(x, params) + +#endif //BOOST_TYPEOF_DECLTYPE_HPP_INCLUDED + diff --git a/include/boost/typeof/msvc/typeof_impl.hpp b/include/boost/typeof/msvc/typeof_impl.hpp index 74ebc70..3071efb 100644 --- a/include/boost/typeof/msvc/typeof_impl.hpp +++ b/include/boost/typeof/msvc/typeof_impl.hpp @@ -15,9 +15,7 @@ # include # include -# if BOOST_WORKAROUND(BOOST_MSVC,>=1310) -# include -# endif +# include namespace boost { @@ -25,7 +23,7 @@ namespace boost { //Compile time constant code -# if BOOST_WORKAROUND(BOOST_MSVC,>=1300) && defined(_MSC_EXTENSIONS) +# if defined(_MSC_EXTENSIONS) template struct the_counter; template @@ -85,26 +83,7 @@ namespace boost //Typeof code -# if BOOST_WORKAROUND(BOOST_MSVC,==1300) - template - struct msvc_extract_type - { - template - struct id2type_impl; - - typedef id2type_impl id2type; - }; - - template - struct msvc_register_type : msvc_extract_type - { - template<> - struct id2type_impl //VC7.0 specific bugfeature - { - typedef T type; - }; - }; -#elif BOOST_WORKAROUND(BOOST_MSVC,>=1400) +# if BOOST_WORKAROUND(BOOST_MSVC,>=1400) struct msvc_extract_type_default_param {}; template @@ -153,60 +132,7 @@ namespace boost }; }; # endif -// EAN: preprocess this block out on advice of Peder Holt -// to eliminate errors in type_traits/common_type.hpp -# if 0 //BOOST_WORKAROUND(BOOST_MSVC,==1310) - template - struct msvc_typeid_wrapper { - typedef typename msvc_extract_type::id2type id2type; - typedef typename id2type::type wrapped_type; - typedef typename wrapped_type::type type; - }; - //This class is used for registering the type T. encode_type is mapped against typeid(encode_type). - //msvc_typeid_wrapper)> will now have a type typedef that equals encode_type. - template - struct encode_type - { - typedef encode_type input_type; - //Invoke registration of encode_type. typeid(encode_type) is now mapped to encode_type. Do not use registered_type for anything. - //The reason for registering encode_type rather than T, is that VC handles typeid(function reference) poorly. By adding another - //level of indirection, we solve this problem. - typedef typename msvc_register_type >::id2type registered_type; - typedef T type; - }; - template typename disable_if< - typename is_function::type, - typename encode_type::input_type>::type encode_start(T const&); - - template typename enable_if< - typename is_function::type, - typename encode_type::input_type>::type encode_start(T&); - - template - msvc_register_type typeof_register_type(const T&); - - -# define BOOST_TYPEOF(expr) \ - boost::type_of::msvc_typeid_wrapper::type - -# define BOOST_TYPEOF_TPL(expr) typename BOOST_TYPEOF(expr) - -# define BOOST_TYPEOF_NESTED_TYPEDEF_TPL(name,expr) \ -struct name {\ - enum {_typeof_register_value=sizeof(typeid(boost::type_of::typeof_register_type(expr)))};\ - typedef typename boost::type_of::msvc_extract_type::id2type id2type;\ - typedef typename id2type::type type;\ -}; - -# define BOOST_TYPEOF_NESTED_TYPEDEF(name,expr) \ -struct name {\ - enum {_typeof_register_value=sizeof(typeid(boost::type_of::typeof_register_type(expr)))};\ - typedef boost::type_of::msvc_extract_type::id2type id2type;\ - typedef id2type::type type;\ -}; - -# else template struct msvc_typeid_wrapper { typedef typename msvc_extract_type >::id2type id2type; @@ -242,7 +168,6 @@ struct name {\ { typedef char(*type)[encode_type::value]; }; -# if BOOST_WORKAROUND(BOOST_MSVC,>=1310) template typename disable_if< typename is_function::type, typename sizer::type>::type encode_start(T const&); @@ -250,10 +175,6 @@ struct name {\ template typename enable_if< typename is_function::type, typename sizer::type>::type encode_start(T&); -# else - template - typename sizer::type encode_start(T const&); -# endif template msvc_register_type typeof_register_type(const T&,Organizer* =0); @@ -264,19 +185,18 @@ struct name {\ # define BOOST_TYPEOF_NESTED_TYPEDEF_TPL(name,expr) \ struct name {\ - BOOST_STATIC_CONSTANT(int,_typeof_register_value=sizeof(boost::type_of::typeof_register_type(expr)));\ + enum {_typeof_register_value=sizeof(boost::type_of::typeof_register_type(expr))};\ typedef typename boost::type_of::msvc_extract_type::id2type id2type;\ typedef typename id2type::type type;\ }; # define BOOST_TYPEOF_NESTED_TYPEDEF(name,expr) \ struct name {\ - BOOST_STATIC_CONSTANT(int,_typeof_register_value=sizeof(boost::type_of::typeof_register_type(expr)));\ + enum {_typeof_register_value=sizeof(boost::type_of::typeof_register_type(expr))};\ typedef boost::type_of::msvc_extract_type::id2type id2type;\ typedef id2type::type type;\ }; -#endif } } diff --git a/include/boost/typeof/native.hpp b/include/boost/typeof/native.hpp old mode 100755 new mode 100644 diff --git a/include/boost/typeof/register_fundamental.hpp b/include/boost/typeof/register_fundamental.hpp old mode 100755 new mode 100644 index 3a15888..a6164ba --- a/include/boost/typeof/register_fundamental.hpp +++ b/include/boost/typeof/register_fundamental.hpp @@ -34,8 +34,7 @@ BOOST_TYPEOF_REGISTER_TYPE(long double) BOOST_TYPEOF_REGISTER_TYPE(wchar_t) #endif -#if (defined(BOOST_MSVC) && (BOOST_MSVC == 1200)) \ - || (defined(BOOST_INTEL_CXX_VERSION) && defined(_MSC_VER) && (BOOST_INTEL_CXX_VERSION <= 600)) \ +#if (defined(BOOST_INTEL_CXX_VERSION) && defined(_MSC_VER) && (BOOST_INTEL_CXX_VERSION <= 600)) \ || (defined(__BORLANDC__) && (__BORLANDC__ == 0x600) && (_MSC_VER == 1200)) BOOST_TYPEOF_REGISTER_TYPE(unsigned __int8) BOOST_TYPEOF_REGISTER_TYPE(__int8) diff --git a/include/boost/typeof/typeof.hpp b/include/boost/typeof/typeof.hpp index 4d56964..1efa3dc 100644 --- a/include/boost/typeof/typeof.hpp +++ b/include/boost/typeof/typeof.hpp @@ -13,7 +13,15 @@ # error both typeof emulation and native mode requested #endif -#if defined(__COMO__) +#include + +#if !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 +# endif + +#elif defined(__COMO__) # ifdef __GNUG__ # ifndef BOOST_TYPEOF_EMULATION # ifndef BOOST_TYPEOF_NATIVE @@ -49,7 +57,7 @@ # endif # endif -#elif defined(__GNUC__) +#elif defined(__GNUC__) || defined(__clang__) # ifndef BOOST_TYPEOF_EMULATION # ifndef BOOST_TYPEOF_NATIVE # define BOOST_TYPEOF_NATIVE @@ -100,17 +108,7 @@ # define MSVC_TYPEOF_HACK # endif #elif defined(_MSC_VER) -# if (_MSC_VER <= 1300) // 6.5, 7.0 -# ifndef BOOST_TYPEOF_EMULATION -# ifndef BOOST_TYPEOF_NATIVE -# define BOOST_TYPEOF_NATIVE -# endif -# include -# define MSVC_TYPEOF_HACK -# else -# error typeof emulation is not supported -# endif -# elif (_MSC_VER >= 1310) // 7.1 -> +# if (_MSC_VER >= 1310) // 7.1 -> # ifndef BOOST_TYPEOF_EMULATION # ifndef BOOST_TYPEOF_NATIVE # ifndef _MSC_EXTENSIONS @@ -171,6 +169,13 @@ # define BOOST_TYPEOF_KEYWORD __typeof__ # endif # endif +#elif defined(__IBM__TYPEOF__) +# ifndef BOOST_TYPEOF_EMULATION +# ifndef BOOST_TYPEOF_NATIVE +# define BOOST_TYPEOF_NATIVE +# endif +# define BOOST_TYPEOF_KEYWORD __typeof__ +# endif #else //unknown compiler # ifndef BOOST_TYPEOF_NATIVE # ifndef BOOST_TYPEOF_EMULATION @@ -206,7 +211,11 @@ #elif defined(BOOST_TYPEOF_NATIVE) # define BOOST_TYPEOF_TEXT "using native typeof" # include -# include +# ifdef BOOST_TYPEOF_DECLTYPE +# include +# else +# include +# endif #else # error typeof configuration error #endif diff --git a/test/function.cpp b/test/function.cpp old mode 100755 new mode 100644 index 86a4df2..f9a4e99 --- a/test/function.cpp +++ b/test/function.cpp @@ -6,3 +6,5 @@ BOOST_STATIC_ASSERT(boost::type_of::test::value); BOOST_STATIC_ASSERT(boost::type_of::test::value); +BOOST_STATIC_ASSERT(boost::type_of::test::value); +BOOST_STATIC_ASSERT(boost::type_of::test::value); diff --git a/test/function_binding.cpp b/test/function_binding.cpp old mode 100755 new mode 100644 index 8ad1cf2..46a6016 --- a/test/function_binding.cpp +++ b/test/function_binding.cpp @@ -7,8 +7,16 @@ #include #include -int foo(double); -typedef int(&FREF)(double); -FREF fref = *foo; +int foo1(double); +int foo2(...); +int foo3(int, ...); +typedef int(&FREF1)(double); +typedef int(&FREF2)(...); +typedef int(&FREF3)(int, ...); +FREF1 fref1 = *foo1; +FREF2 fref2 = *foo2; +FREF3 fref3 = *foo3; -BOOST_STATIC_ASSERT((boost::is_same::value)); +BOOST_STATIC_ASSERT((boost::is_same::value)); +BOOST_STATIC_ASSERT((boost::is_same::value)); +BOOST_STATIC_ASSERT((boost::is_same::value)); diff --git a/test/function_ptr.cpp b/test/function_ptr.cpp old mode 100755 new mode 100644 index c6babfb..977546a --- a/test/function_ptr.cpp +++ b/test/function_ptr.cpp @@ -8,12 +8,19 @@ BOOST_STATIC_ASSERT(boost::type_of::test::value); BOOST_STATIC_ASSERT(boost::type_of::test::value); BOOST_STATIC_ASSERT(boost::type_of::test::value); BOOST_STATIC_ASSERT(boost::type_of::test::value); +BOOST_STATIC_ASSERT(boost::type_of::test::value); +BOOST_STATIC_ASSERT(boost::type_of::test::value); // check that const gets stripped from function pointer -int foo(double); -typedef int(*PTR)(double); -typedef const PTR CPTR; -CPTR cptr = foo; +int foo1(double); +int foo2(...); +typedef int(*PTR1)(double); +typedef int(*PTR2)(...); +typedef const PTR1 CPTR1; +typedef const PTR2 CPTR2; +CPTR1 cptr1 = foo1; +CPTR2 cptr2 = foo2; -BOOST_STATIC_ASSERT((boost::is_same::value)); +BOOST_STATIC_ASSERT((boost::is_same::value)); +BOOST_STATIC_ASSERT((boost::is_same::value)); diff --git a/test/function_ptr_from_tpl.cpp b/test/function_ptr_from_tpl.cpp old mode 100755 new mode 100644 index 7b880a2..c048ede --- a/test/function_ptr_from_tpl.cpp +++ b/test/function_ptr_from_tpl.cpp @@ -6,15 +6,23 @@ #include #include -void f() -{} +void f1() {} +void f2(...) {} template -struct tpl +struct tpl1 { - typedef BOOST_TYPEOF_TPL(&f) type; + typedef BOOST_TYPEOF_TPL(&f1) type; }; -typedef void(*fun_type)(); +template +struct tpl2 +{ + typedef BOOST_TYPEOF_TPL(&f2) type; +}; + +typedef void(*fun1_type)(); +typedef void(*fun2_type)(...); -BOOST_STATIC_ASSERT((boost::is_same::type, fun_type>::value)); +BOOST_STATIC_ASSERT((boost::is_same::type, fun1_type>::value)); +BOOST_STATIC_ASSERT((boost::is_same::type, fun2_type>::value)); diff --git a/test/function_ref.cpp b/test/function_ref.cpp old mode 100755 new mode 100644 index b524e2a..0651276 --- a/test/function_ref.cpp +++ b/test/function_ref.cpp @@ -6,3 +6,5 @@ BOOST_STATIC_ASSERT(boost::type_of::test::value); BOOST_STATIC_ASSERT(boost::type_of::test::value); +BOOST_STATIC_ASSERT(boost::type_of::test::value); +BOOST_STATIC_ASSERT(boost::type_of::test::value); diff --git a/tools/preprocess.pl b/tools/preprocess.pl index a21e98a..56f50c5 100644 --- a/tools/preprocess.pl +++ b/tools/preprocess.pl @@ -1,7 +1,7 @@ # // (C) Copyright Tobias Schwinger # // # // Use modification and distribution are subject to the boost Software License -# // Version 1.0. (See http:/\/www.boost.org/LICENSE_1_0.txt). +# // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt). # // Preprocess and run this script. # //