boostorg / type_traits Goto Github PK
View Code? Open in Web Editor NEWBoost.org type_traits module
Home Page: http://boost.org/libs/type_traits
Boost.org type_traits module
Home Page: http://boost.org/libs/type_traits
The xcode8.2
, xcode8.1
configurations say
This job was configured to run on an OS X image that was retired on November 28, 2017. It was routed to our Xcode 8.3 image.
(but the 8.3 part is wrong and they actually use the default 9.4.)
xcode8.0
doesn't exist at all, and also falls back to the default. Should be xcode8
.
xcode6.4
says
Running builds with Xcode 6.4 in Travis CI is deprecated and will be removed in January 2019.
See https://docs.travis-ci.com/user/reference/osx#os-x-version
I'm trying to build an unmanaged project where I can't enable /clr, I upgraded the Boost libraries from v1.67 to 1.71, and keep getting this error for some files that uses boost:
>c:\..\..\thirdparty\source\boost\boost_1_71_0\boost\type_traits\detail\is_function_cxx_11.hpp(102): error C3193: '__clrcall': requires '/clr' or '/ZW' command line option
I tried to turn on the /clr option only for those specific files, but it becomes a whole mess with some project dependencies ..
Is there any solution or workaround for this?
This is what I have (CI_SUPPRESS_KNOWN_ISSUES has been defined):
Cygwin g++ 6.3.0:
testing.capture-output ..\..\bin.v2\libs\type_traits\test\alignment_of_a2_test.test\gcc-cxx03-6.3.0\debug\alignment_of_a2_test.run
====== BEGIN OUTPUT ======
test\alignment_of_a2_test.cpp:95: The expression: "::boost::alignment_of<double>::value" had an invalid value (found 8, expected 4)
test\alignment_of_a2_test.cpp:98: The expression: "::boost::alignment_of< ::boost::long_long_type>::value" had an invalid value (found 8, expected 4)
EXIT STATUS: 2
====== END OUTPUT ======
testing.capture-output ..\..\bin.v2\libs\type_traits\test\alignment_of_test.test\gcc-cxx03-6.3.0\debug\alignment_of_test.run
====== BEGIN OUTPUT ======
test\alignment_of_test.cpp:90: The expression: "::boost::alignment_of<double>::value" had an invalid value (found 8, expected 4)
test\alignment_of_test.cpp:93: The expression: "::boost::alignment_of< ::boost::long_long_type>::value" had an invalid value (found 8, expected 4)
EXIT STATUS: 2
====== END OUTPUT ======
(same for c++11, 14, 1z)
Cygwin clang++ 4.0.1 -std=c++1z:
clang-linux.compile.c++.without-pth ..\..\bin.v2\libs\type_traits\test\has_nothrow_destructor_test.test\clang-linux-cxx1z-4.0.1\debug\has_nothrow_destructor_test.obj
In file included from test\has_nothrow_destructor_test.cpp:12:
test/test.hpp:210:9: warning: 'const' qualifier on reference type 'r_type' (aka'int &') has no effect [-Wignored-qualifiers]
typedef const r_type cr_type;
^~~~~~
test\has_nothrow_destructor_test.cpp:37:21: error: ISO C++1z does not allow dynamic exception specifications [-Wdynamic-exception-spec]
~throwing_base() throw(int);
^~~~~~~~~~
test\has_nothrow_destructor_test.cpp:37:21: note: use 'noexcept(false)' instead
~throwing_base() throw(int);
^~~~~~~~~~
noexcept(false)
1 warning and 1 error generated.
Appveyor has Cygwin:
https://github.com/boostorg/system/blob/develop/appveyor.yml#L25
Travis has clang++ 4:
https://github.com/boostorg/smart_ptr/blob/develop/.travis.yml#L479
Since d3ac8b9 boost::decay
strips cv-qualifiers, but the documentation was never adjusted accordingly:
Let
U
be the result ofremove_reference<T>::type
, then ifU
is an array type, the result isremove_extent<U>::type*
, otherwise ifU
is a function type then the result isU*
, otherwise the result isU
.
is_complete<T&>::value
is currently defined to be the value of is_complete<T>::value
. This is incorrect. According to the standard, all lvalue reference types and rvalue reference types are complete types.
In [basic.types]:
A class that has been declared but not defined, an enumeration type in certain contexts (9.6), or an array of unknown bound or of incomplete element type, is an incompletely-defined object type. Incompletely-defined object types and cv void are incomplete types (6.7.1). Objects shall not be defined to have an incomplete type.
References do not fall under any of the above cases and are therefore complete.
As someone else reported in the mailing list:
1>c:\quinesoftwarebase\include\boost\type_traits\detail\is_member_function_pointer_cxx_11.hpp(114):
error C2764: 'C': template parameter not used or deducible in partial
specialization 'boost::is_member_function_pointer<Ret(Args...)>'
1>c:\quinesoftwarebase\include\boost\type_traits\detail\is_member_function_pointer_cxx_11.hpp(125):
warning C4575: '__vectorcall' incompatible with the '/clr' option:
converting to '__stdcall'
Basically the __clrcall variant isn't using the C template parameter, so I adjusted them to match the other calling convention variants.
Several calling conventions exist/do not exist/default differently based on x86/x64 settings and enabling CLR so adjusted the #if logic accordingly.
I've adjusted these files to deal with the problems; provided to assist:
Add the moment function_traits
works for void () noexcept
, but not for void () const
or void () &
.
If we fix that, it would be a good opportunity to also add
{
template<class...> struct list {};
using arguments = list<A1, A2, ..., An>;
}
(on C++11) which can be further manipulated with Mp11. (The argN_type
typedefs aren't generic.)
Like the global namespace injection in include/bind.hpp, this needs to begin being deprecated immediately and removed in a near future Boost as it causes symbol collision between incompatible Boosts:
boost/mpl/aux_/adl_barrier.hpp:# define BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE mpl_
boost/mpl/aux_/adl_barrier.hpp:# define BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_OPEN namespace mpl_ {
boost/type_traits/integral_constant.hpp:namespace mpl_{
boost/type_traits/integral_constant.hpp: using ::mpl_::bool_;
boost/type_traits/integral_constant.hpp: using ::mpl_::integral_c;
boost/type_traits/integral_constant.hpp: using ::mpl_::integral_c_tag;
Moved from https://svn.boost.org/trac10/ticket/3783
This test determines that the __alignof() operator returns the same value as an actual compiler alignment. However the __alignof (type) is suppose to return the minimal required alignment for the type, not the actual alignment the compiler uses. So on IA32 where an alignment of 1 works, and the ABI specifies a minimum of 4; __alignof(type) returns 4, which is correct. However in almost all cases the compiler will align at 8, for performance reasons and the test fails. On all other configs we tested the actual, and minimal alignment for clang 6.0 are the same.
Leading to misinformed comment here https://github.com/boostorg/type_traits/include/boost/type_traits/intrinsics.hpp#L289
and a fall-back of not using actual __alignof() operator for most of Boost's supported platforms.
error: class template partial specialization contains a template parameter that cannot be deduced; this partial specialization will never be used [-Wunusable-partial-specialization]
struct is_function<Ret BOOST_TT_DEF_CALL(Args...)BOOST_TT_NOEXCEPT_DECL> : public true_type {};
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It's similar to #118, but not exactly the same. When including the headers of type_traits, the error messages are:
.../boost/type_traits/detail/is_function_cxx_11.hpp(386): error C2953: 'boost::is_function<Ret(Args...) noexcept>': class template has already been defined
.../boost/type_traits/detail/is_function_cxx_11.hpp(316): note: see declaration of 'boost::is_function<Ret(Args...) noexcept>'
...
Looks like the compiler takes __cdecl, __stdcall, and __fastcall the same thing.
is_base_of
provides functionality to check whether a particular type is inherited from another particular type or not. But when the parent class is a templated class and want to check if the given type is inherited from any instance of the template it becomes hard to do it with is_base_of
. Consider the example below:
template<typename X>
class base{};
class derived: public base<int>{};
now if I want to use is_base_of
with this hierarchy it would look something like:
boost::is_base_of<base<X>, derived>::value;
and here X needs to be specified every time. But I would like to propose a way in which we don't need to specify the X and we can omit the base template argument and check general instance of the base.
So if this seems good then I would like to submit the pull request for the same.
__has_feature
and __has_builtin
on clang don't help to detect move ctor/assing checking intrinsic, see https://wandbox.org/permlink/PagEil6PmRSgjELM , thus boost::has_trivial_move_*
don't work...
Both of the intrinsics are introduced on clang 3.3 release, so I'm trying to detect those via other feature.
Source Code:
#include <boost/lexical_cast.hpp>
#include <string>
#include <iostream>
float getSomeNumber()
{
return 10.0;
}
int main(int argc, char** argv)
{
std::string mystring("Hello: " + boost::lexical_cast<std::string>(getSomeNumber());
std::cout << mystring << std::endl;
return 0;
}
Intel Compiler 16:
/boost/1.67.0/include/boost/type_traits/is_complete.hpp(45): warning #70: incomplete type is not allowed
ok_tag<sizeof(T)> check_is_complete(int);
detected during ....
...
/boost/1.67.0/include/boost/type_traits/is_complete.hpp(51): error: template instantiation resulted in unexpected function type of "boost::detail::ok_tag<1U> (int)" (the meaning of a name may have changed since the template declaration -- the type of the template is "boost::detail::ok_tag<sizeof(T)> (int)")
...
detected during:
instantiation of "boost::detail::check_is_complete" based on template argument <void> at line 51
instantiation of class "boost::is_complete<T> [with T=void]" at line 484 of "/Path/to/boost/include/boost/type_traits/is_convertible.hpp"
...
instantiation of "Target boost::lexical_cast<Target, Source>(const Source &) [with Target=std::string, Source=float]" at line 11 of "boostTest.cc"
Trying to build boost-regex
with vcpkg with arm-static-windows
triplet (modified arm-windows
with static linkage) fails with following errors:
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(106): error C2953: 'boost::is_function<Ret(Args...)>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(36): note: see declaration of 'boost::is_function<Ret(Args...)>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(109): error C2953: 'boost::is_function<Ret(Args...)>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(36): note: see declaration of 'boost::is_function<Ret(Args...)>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(123): error C2953: 'boost::is_function<Ret(Args...) const>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(41): note: see declaration of 'boost::is_function<Ret(Args...) const>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(126): error C2953: 'boost::is_function<Ret(Args...) const>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(41): note: see declaration of 'boost::is_function<Ret(Args...) const>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(140): error C2953: 'boost::is_function<Ret(Args...) volatile>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(46): note: see declaration of 'boost::is_function<Ret(Args...) volatile>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(143): error C2953: 'boost::is_function<Ret(Args...) volatile>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(46): note: see declaration of 'boost::is_function<Ret(Args...) volatile>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(157): error C2953: 'boost::is_function<Ret(Args...) volatile const>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(51): note: see declaration of 'boost::is_function<Ret(Args...) volatile const>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(160): error C2953: 'boost::is_function<Ret(Args...) volatile const>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(51): note: see declaration of 'boost::is_function<Ret(Args...) volatile const>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(175): error C2953: 'boost::is_function<Ret(Args...) &>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(58): note: see declaration of 'boost::is_function<Ret(Args...) &>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(178): error C2953: 'boost::is_function<Ret(Args...) &>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(58): note: see declaration of 'boost::is_function<Ret(Args...) &>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(192): error C2953: 'boost::is_function<Ret(Args...) const &>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(63): note: see declaration of 'boost::is_function<Ret(Args...) const &>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(195): error C2953: 'boost::is_function<Ret(Args...) const &>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(63): note: see declaration of 'boost::is_function<Ret(Args...) const &>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(209): error C2953: 'boost::is_function<Ret(Args...) volatile &>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(68): note: see declaration of 'boost::is_function<Ret(Args...) volatile &>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(212): error C2953: 'boost::is_function<Ret(Args...) volatile &>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(68): note: see declaration of 'boost::is_function<Ret(Args...) volatile &>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(226): error C2953: 'boost::is_function<Ret(Args...) volatile const &>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(73): note: see declaration of 'boost::is_function<Ret(Args...) volatile const &>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(229): error C2953: 'boost::is_function<Ret(Args...) volatile const &>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(73): note: see declaration of 'boost::is_function<Ret(Args...) volatile const &>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(244): error C2953: 'boost::is_function<Ret(Args...) &&>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(80): note: see declaration of 'boost::is_function<Ret(Args...) &&>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(247): error C2953: 'boost::is_function<Ret(Args...) &&>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(80): note: see declaration of 'boost::is_function<Ret(Args...) &&>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(261): error C2953: 'boost::is_function<Ret(Args...) const &&>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(85): note: see declaration of 'boost::is_function<Ret(Args...) const &&>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(264): error C2953: 'boost::is_function<Ret(Args...) const &&>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(85): note: see declaration of 'boost::is_function<Ret(Args...) const &&>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(278): error C2953: 'boost::is_function<Ret(Args...) volatile &&>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(90): note: see declaration of 'boost::is_function<Ret(Args...) volatile &&>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(281): error C2953: 'boost::is_function<Ret(Args...) volatile &&>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(90): note: see declaration of 'boost::is_function<Ret(Args...) volatile &&>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(295): error C2953: 'boost::is_function<Ret(Args...) volatile const &&>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(95): note: see declaration of 'boost::is_function<Ret(Args...) volatile const &&>'
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(298): error C2953: 'boost::is_function<Ret(Args...) volatile const &&>': class template has already been defined
C:\Users\user\vcpkg\installed\arm-static-windows\include\boost/type_traits/detail/is_function_cxx_11.hpp(95): note: see declaration of 'boost::is_function<Ret(Args...) volatile const &&>'
You can find full log as provided by vcpkg here: https://gist.github.com/janisozaur/cf45cb9990da6044ef75621e9e104b3f
====== BEGIN OUTPUT ======
test\has_nothrow_copy_test.cpp:243: The expression: "::boost::has_nothrow_copy<delete_move>::value" had an invalid value (found 1, expected 0)
EXIT STATUS: 1
====== END OUTPUT ======
I have define=CI_SUPPRESS_KNOWN_ISSUES
on the command line. Interestingly, Appveyor passes.
I see
#if !(defined(CI_SUPPRESS_KNOWN_ISSUES) && BOOST_WORKAROUND(BOOST_GCC, < 40600)) && !(defined(CI_SUPPRESS_KNOWN_ISSUES) && BOOST_WORKAROUND(BOOST_MSVC, == 1800))
All right, this middle &&
probably needs to be ||
, but why does Appveyor pass? It's a mystery.
Triggers this error:
Warning C4561
'__fastcall' incompatible with the '/clr' option: converting to '__stdcall'
...\include\boost\type_traits\detail\is_member_function_pointer_cxx_11.hpp 120
Error C2953
'boost::is_member_function_pointer<Ret(__stdcall C::* )(Args...)>': class template has already been defined
...\include\boost\type_traits\detail\is_member_function_pointer_cxx_11.hpp 120
The fix is attached.
clr_patch.txt
type_traits/include/boost/type_traits/intrinsics.hpp
Lines 228 to 235 in efc0be6
When I compile this with clang-cl on Windows, I get the following error (in Boost 1.68, but the code appears unchanged here):
T:\boost\boost_1_68_0\include\boost/type_traits/has_trivial_move_assign.hpp(49): error : no template named 'is_assignable'; did you mean 'std::is_assignable'?
T:\boost\boost_1_68_0\include\boost/type_traits/intrinsics.hpp(233): note: expanded from macro 'BOOST_HAS_TRIVIAL_MOVE_ASSIGN'
It does seem peculiar that this is being called unqualified here.
If you include a boost header (such as boost/algorithm/string.hpp) that ultimately includes is_funcion_cxx_11.hpp in a C++/CLI .NET Core (NOT the normal .NET Framework) project, you will see a series of compiler warnings similar to the following:
boost-1.74\boost\type_traits\detail\is_function_cxx_11.hpp(114,4): warning C4575: '__vectorcall' incompatible with the '/clr' option: converting to '__stdcall'
There is no warning here if the C++/CLI project is compiled as .NET Framework instead. It looks like __CLR_VER is defined when building as .NET Framework, but not when building as .NET Core?
How to convert your C++/CLI project to build as .NET Core (instead of the normal .NET Framework):
https://docs.microsoft.com/en-us/dotnet/core/porting/cpp-cli
a lot of errors in packages\boost.1.69.0.0\lib\native\include\boost\type_traits\detail\is_member_function_pointer_cxx_11.hpp
Severity Code Description Project File Line Suppression State
Error C2764 'C': template parameter not used or deducible in partial specialization 'boost::is_member_function_pointer<Ret(Args...) volatile const &>' packages\boost.1.69.0.0\lib\native\include\boost\type_traits\detail\is_member_function_pointer_cxx_11.hpp 220
another error:
Severity Code Description Project File Line Suppression State
Error C2059 syntax error: 'generic' \packages\boost.1.69.0.0\lib\native\include\boost\filesystem\path.hpp 579
can someone help, thanks
For example: (x86 compiler)
using Arg = boost::function_traits<int(__stdcall)(int)>::arg1_type;
Sample:
https://godbolt.org/z/vPfz4Yjvh
is_member_func_test
fails for GCC 4.8.1 as shown in
The problem here is that is_member_function_pointer.hpp
dispatches to a C++11 implementation or a C++03 one depending on whether BOOST_TT_HAS_ASCCURATE_IS_FUNCTION
is defined or not:
type_traits/include/boost/type_traits/detail/config.hpp
Lines 84 to 87 in 17af798
And BOOST_GCC
is 40801 for the offending compiler. I guess the fix is as simple as changing BOOST_WORKAROUND(BOOST_GCC, <= 40800)
to BOOST_WORKAROUND(BOOST_GCC, < 40900)
.
boost::is_function
currently does not handle noexcept function types which is distinct from non-noexcept function types. e.g.
#include <boost/type_traits.hpp>
#include <type_traits>
void foo(int){}
void bar(int) noexcept{}
int main(){
static_assert(boost::is_function<decltype(foo)>::value);
static_assert(boost::is_function<decltype(bar)>::value);
return 0;
}
Both GCC 7.2 and Clang 5.0 failed the second assertion if compiled with -std=c++1z
flag.
Plus, boost::is_member_function_pointer
has the same issue too.
Boost version is 1.65.1.
we found Boost version 1.70.0 b1 not compiling against our code base with C++17 and MSVC version 1916 in conjunction with the /Zc:noexceptTypes-
compiler flag. Resulting error is of type:
boost\type_traits\detail\is_member_function_pointer_cxx_11.hpp(359): error C2953: 'boost::is_member_function_pointer<Ret(__cdecl C::* )(Args...)>': class template has already been defined
boost\type_traits\detail\is_member_function_pointer_cxx_11.hpp(48): note: see declaration of 'boost::is_member_function_pointer<Ret(__cdecl C::* )(Args...)>'
template<class Pm> struct remove_member_pointer
{
typedef Pm type;
};
template<class T, class C> struct remove_member_pointer<T C::*>
{
typedef T type;
};
In fact it flat out fails to compile with msvc.
#include <boost/type_traits/is_function.hpp>
#include <boost/core/lightweight_test_trait.hpp>
struct X
{
void f() {}
void fc() const {}
void fv() volatile {}
void fcv() const volatile {}
};
template< class C, class F > void test( F C::* )
{
BOOST_TEST_TRAIT_TRUE(( boost::is_function< F > ));
}
int main()
{
test( &X::f );
test( &X::fc );
test( &X::fv );
test( &X::fcv );
return boost::report_errors();
}
Moved from https://svn.boost.org/trac10/ticket/10934
integral_constant
has this conversion operator to mpl::integral_c
:
operator const mpl::integral_c<T, val>& ()const
{
static const char data[sizeof(long)] = { 0 };
static const void* pdata = data;
return *(reinterpret_cast<const mpl::integral_c<T, val>*>(pdata));
}
which unfortunately is not / cannot be constexpr
. (The integral_constant<bool, meow>
partial specialization has a similar conversion to lvalue mpl::bool_<meow>
.) These conversions are used in the initialization of lots of constant data in Boost::math, which could otherwise have constant initialization but sadly currently has dynamic initialization since these conversions are not constexpr
.
Is there any way these could be made constexpr
conversions to avoid that dynamic initialization?
is_default_constructible
fails to compile on a pair that has one element which is not DefaultConstructible. This happens on clang, haven't seen it on gcc.
Hey John, release process starting - can we merge soon?
I encountered this in Boost 1.68; I have not verified it in current Boost but I did manually inspect the relevant code and it appears to be unchanged, so I suspect the issue is still present.
If you apply the [[nodiscard]]
attribute to various operators (such as operator==
and operator+
) -- as seems sensible as these are pure functions -- then VS2017 at least produces a warning that the return value is discarded:
t:\boost\boost_1_68_0\include\boost\type_traits\detail\has_binary_operator.hpp(149): warning C4834: discarding return value of function with 'nodiscard' attribute
t:\boost\boost_1_68_0\include\boost\type_traits\detail\has_binary_operator.hpp(233): note: see reference to class template instantiation 'boost::detail::has_equal_to_impl::operator_returns_void<Lhs,Rhs>' being compiled
(In my case this originated from a call to boost::has_equal_to
and boost::has_less
(and thus operator==
and operator<
), but it would presumably affect any other binary operator, and most likely other operator types as well.)
Most likely this just needs an explicit cast to void
to silence the warning.
For this code:
#include <boost/type_traits/is_final.hpp>
#include <type_traits>
#include <iostream>
struct final1 final {};
template <typename T> struct final2 final {};
int main() {
std::cout << "boost::is_final<final1>: " << boost::is_final<final1>::value << std::endl;
std::cout << "boost::is_final<final2<int>>::value: " << boost::is_final<final2<int>>::value << std::endl;
std::cout << "std::is_final<final1>: " << std::is_final<final1>::value << std::endl;
std::cout << "std::is_final<final2<int>>::value: " << std::is_final<final2<int>>::value << std::endl;
}
GCC 6.4.0 outputs:
boost::is_final<final1>: 1
boost::is_final<final2<int>>::value: 0
std::is_final<final1>: 1
std::is_final<final2<int>>::value: 1
I'd expect all values to be 1
. I get that for Clang.
#include <boost/type_traits.hpp>
#include <type_traits>
struct foo {
foo(foo const&) = delete; // deleted copy constructor
foo& operator=(foo const&) = default;
};
struct bar {
bar(bar const&) = default;
bar(bar &&) {} // user defined move constructor
auto operator=(bar const&) -> bar& = default;
auto operator=(bar && ) -> bar& { return *this; } // user defined move assignment
};
static_assert(not boost::is_trivially_copyable<foo>::value);
static_assert( std ::is_trivially_copyable<foo>::value);
static_assert( boost::is_trivially_copyable<bar>::value);
static_assert(not std ::is_trivially_copyable<bar>::value);
https://en.cppreference.com/w/cpp/named_req/TriviallyCopyable
types with deleted constructors/move assignment operators are allowed to be trivially copyable, as long as at least one of them is defined, and all the non deleted ones are trivial.
Recently, I had met:
/usr/include/boost/type_traits/is_empty.hpp:78: Parenthesis/brace mismatch between #if and #else branches; using #if branch
It was because of missing the )
of BOOST_STATIC_CONSTANT
.
===============================
I can not find this file in this github, so I open this issue.
Maybe this issue can do some help :)
The following code assertion-fails on GCC 4.7:
#include <boost/type_traits.hpp>
struct X
{
X(X&&) noexcept(false) { throw 0; }
};
X&& make_X() noexcept;
int main()
{
static_assert(!boost::is_nothrow_move_constructible<X>::value, "** 1");
static_assert(!noexcept(X(make_X())), "** 2");
}
(see the failure online at https://wandbox.org/permlink/mTBxqXQED1ts34uF)
This is because the trait is expanded to:
template <class T>
struct is_nothrow_move_constructible
: public integral_constant<bool,
(::boost::has_trivial_move_constructor<T>::value || ::boost::has_nothrow_copy<T>::value) && !::boost::is_array<T>::value>
{};
And boost::has_nothrow_copy<T>::value
works incorrectly on this compiler:
#include <boost/type_traits.hpp>
struct X
{
X(X&&) = delete;
};
int main()
{
static_assert(!::boost::has_nothrow_copy<X>::value, "** 2");
}
Hi,
I get compiler errors when trying to compile with 32 bit and CLR using Visual Studio 2017:
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(388): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(388): error C2953: 'boost::is_function<Ret(Args...) noexcept>': class template has already been defined
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(386): note: see declaration of 'boost::is_function<Ret(Args...) noexcept>'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(403): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(403): error C2953: 'boost::is_function<Ret(Args...) noexcept const>': class template has already been defined
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(401): note: see declaration of 'boost::is_function<Ret(Args...) noexcept const>'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(418): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(418): error C2953: 'boost::is_function<Ret(Args...) noexcept volatile>': class template has already been defined
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(416): note: see declaration of 'boost::is_function<Ret(Args...) noexcept volatile>'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(433): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(433): error C2953: 'boost::is_function<Ret(Args...) noexcept volatile const>': class template has already been defined
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(431): note: see declaration of 'boost::is_function<Ret(Args...) noexcept volatile const>'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(449): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(449): error C2953: 'boost::is_function<Ret(Args...) noexcept &>': class template has already been defined
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(447): note: see declaration of 'boost::is_function<Ret(Args...) noexcept &>'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(464): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(464): error C2953: 'boost::is_function<Ret(Args...) noexcept const &>': class template has already been defined
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(462): note: see declaration of 'boost::is_function<Ret(Args...) noexcept const &>'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(479): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(479): error C2953: 'boost::is_function<Ret(Args...) noexcept volatile &>': class template has already been defined
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(477): note: see declaration of 'boost::is_function<Ret(Args...) noexcept volatile &>'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(494): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(494): error C2953: 'boost::is_function<Ret(Args...) noexcept volatile const &>': class template has already been defined
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(492): note: see declaration of 'boost::is_function<Ret(Args...) noexcept volatile const &>'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(510): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(510): error C2953: 'boost::is_function<Ret(Args...) noexcept &&>': class template has already been defined
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(508): note: see declaration of 'boost::is_function<Ret(Args...) noexcept &&>'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(525): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(525): error C2953: 'boost::is_function<Ret(Args...) noexcept const &&>': class template has already been defined
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(523): note: see declaration of 'boost::is_function<Ret(Args...) noexcept const &&>'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(540): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(540): error C2953: 'boost::is_function<Ret(Args...) noexcept volatile &&>': class template has already been defined
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(538): note: see declaration of 'boost::is_function<Ret(Args...) noexcept volatile &&>'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(555): warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall'
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(555): error C2953: 'boost::is_function<Ret(Args...) noexcept volatile const &&>': class template has already been defined
libraries\boost\type_traits\detail\is_function_cxx_11.hpp(553): note: see declaration of 'boost::is_function<Ret(Args...) noexcept volatile const &&>'
Hi
File is_complete.hpp make warning in line 47:
template <unsigned N>
struct ok_tag { double d; char c[N]; };
template <class T>
ok_tag<sizeof(T)> check_is_complete(int);
specialization ok_tag<sizeof(T)> check_is_complete(int); make implicit cast from unsigned long long (size_t is unsigned long long on 64 arch) to unsigned (32bits) and ugly warning on output.
It may be easy overcome and make more portable by:
template <size_t N>
struct ok_tag { double d; char c[N]; };
Currently on Windows with MSVC10 boost defines BOOST_IS_BASE_OF (which is used in is_base_and_derived, which is used in is_base_of) as follows:
#define BOOST_IS_BASE_OF(T,U) (__is_base_of(T,U) && !is_same<T,U>::value)
But microsoft's intrinsic __is_base_of cannot be used with the same type (i.e. T = U) when it (the type) is not defined.
When the following is compiled
class A;
typedef typename boost::is_base_of<A, A>::type x;
you get an error message:
...\include\boost\type_traits\is_base_and_derived.hpp(228) : error C2139: 'A' : an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_base_of'
...\include\boost\type_traits\is_base_of.hpp(29) : see reference to class template instantiation 'boost::detail::is_base_and_derived_impl<B,D>' being compiled
with
[
B=A,
D=A
]
The same code compiles on gcc-4.8.2 and clang-3.6.
Moved from https://svn.boost.org/trac10/ticket/11422
Boost 1.67.0+ uses boost::void_t<>
in many traits, although it is only defined if BOOST_NO_CXX11_TEMPLATE_ALIASES
is not defined.
This causes compile issues on platforms using those includes where template aliases are not available (or BOOST_NO_CXX11_TEMPLATE_ALIASES
is set).
See: https://svn.boost.org/trac10/ticket/8990.
Patches are supplied.
I know that C++11 on GCC < 4.7 is awful, but true
is not a good default if there is not way to determine noexceptness.
#include <boost/type_traits/is_nothrow_move_assignable.hpp>
struct foo
{
foo& operator=(foo&&) noexcept(false) { throw 0; }
};
static_assert(!boost::is_nothrow_move_assignable<foo>::value, "");
This code in config.hpp:
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !BOOST_WORKAROUND(BOOST_GCC, < 40900)\
&& !BOOST_WORKAROUND(BOOST_MSVC, < 1900) && !BOOST_WORKAROUND(__clang_major__, <= 4)
# define BOOST_TT_HAS_ASCCURATE_IS_FUNCTION
#endif
Can generate a warning or error as __clang_major___WORKAROUND_GUARD is not defined.
If you try to compile this with VS 2017 15.9.5 using boost 1.69 you get 60 errors and 48 warnings
(It does compile with boost 1.68)
Error C2764
'C': template parameter not used or deducible in partial specialization 'boost::is_member_function_pointer<Ret(Args...)>'
boost\type_traits\detail\is_member_function_pointer_cxx_11.hpp 114
Warning C4561
'__fastcall' incompatible with the '/clr' option: converting to '__stdcall'
boost\type_traits\detail\is_member_function_pointer_cxx_11.hpp 120
Error C2953
'boost::is_member_function_pointer<Ret(__stdcall C::* )(Args...)>': class template has already been defined
boost\type_traits\detail\is_member_function_pointer_cxx_11.hpp 120
...
with best regards
Hendrik
Boost.TypeTraits is missing traits is_trivial
and is_trivially_copyable
. It is very tricky to implement them using has_trivial_constructor
and others. It would be really useful to have is_trivial
which degrades to is_pod
on older compilers and is std::is_trivial
on the newer.
I've enhanced the superproject Appveyor (and Travis) to run the tests for the library updated in the commit:
https://ci.appveyor.com/project/boostorg/boost/build/1.0.3623
But type_traits fails because - I assume - CI_SUPPRESS_KNOWN_ISSUES isn't set.
Since this Appveyor support is generic and not specific to a library, I'd rather not include library-specific workarounds in it such as this one; so maybe the test Jamfile could detect Appveyor and Travis using for example [ os.environ CI ]
and turn on the workarounds automatically?
We use gccxml
(some deprecated gcc to XML tool relying on old gcc, e.g. 4.9.3, versions) for code generation and encountered a problem when including boost/type_traits.hpp
from newer boost versions. The expression for getting the result_type
size of the common type of T()
and U()
somehow generated illegal "node identifiers" for gccxml.
I'm not sure if this is really worth fixing, but it worked for older boost versions and the following workaround fixes the issue for us:
diff -rpu boost_1_66_0_old/boost/type_traits/detail/common_arithmetic_type.hpp boost_1_66_0/boost/type_traits/detail/common_arithmetic_type.hpp
--- boost_1_66_0_old/boost/type_traits/detail/common_arithmetic_type.hpp 2017-12-14 00:56:49.000000000 +0100
+++ boost_1_66_0/boost/type_traits/detail/common_arithmetic_type.hpp 2018-04-26 14:14:44.020680512 +0200
@@ -205,10 +205,11 @@ private:
#endif
static bool cond();
+ static const int selector = sizeof(select( cond()? T(): U() ));
public:
- typedef typename arithmetic_type< sizeof(select( cond()? T(): U() )) >::type type;
+ typedef typename arithmetic_type< selector >::type type;
};
} // namespace type_traits_detail
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.