mirror of
https://github.com/boostorg/container_hash.git
synced 2025-08-05 15:34:36 +02:00
is_described_class should be false for unions
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
#define BOOST_HASH_IS_DESCRIBED_CLASS_HPP_INCLUDED
|
#define BOOST_HASH_IS_DESCRIBED_CLASS_HPP_INCLUDED
|
||||||
|
|
||||||
#include <boost/type_traits/integral_constant.hpp>
|
#include <boost/type_traits/integral_constant.hpp>
|
||||||
|
#include <boost/type_traits/is_union.hpp>
|
||||||
#include <boost/describe/bases.hpp>
|
#include <boost/describe/bases.hpp>
|
||||||
#include <boost/describe/members.hpp>
|
#include <boost/describe/members.hpp>
|
||||||
|
|
||||||
@@ -17,7 +18,9 @@ namespace container_hash
|
|||||||
#if defined(BOOST_DESCRIBE_CXX11)
|
#if defined(BOOST_DESCRIBE_CXX11)
|
||||||
|
|
||||||
template<class T> struct is_described_class: boost::integral_constant<bool,
|
template<class T> struct is_described_class: boost::integral_constant<bool,
|
||||||
describe::has_describe_bases<T>::value && describe::has_describe_members<T>::value>
|
describe::has_describe_bases<T>::value &&
|
||||||
|
describe::has_describe_members<T>::value &&
|
||||||
|
!boost::is_union<T>::value>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -107,3 +107,5 @@ run is_described_class_test.cpp
|
|||||||
: : : <warnings>extra ;
|
: : : <warnings>extra ;
|
||||||
run is_described_class_test2.cpp
|
run is_described_class_test2.cpp
|
||||||
: : : <warnings>extra ;
|
: : : <warnings>extra ;
|
||||||
|
run is_described_class_test3.cpp
|
||||||
|
: : : <warnings>extra ;
|
||||||
|
31
test/is_described_class_test3.cpp
Normal file
31
test/is_described_class_test3.cpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
// Copyright 2022 Peter Dimov.
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/container_hash/is_described_class.hpp>
|
||||||
|
#include <boost/describe/class.hpp>
|
||||||
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
|
||||||
|
union Y1
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
BOOST_DESCRIBE_STRUCT( Y1, (), () )
|
||||||
|
|
||||||
|
union Y2
|
||||||
|
{
|
||||||
|
int m1;
|
||||||
|
float m2;
|
||||||
|
};
|
||||||
|
|
||||||
|
BOOST_DESCRIBE_STRUCT( Y2, (), (m1, m2) )
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using boost::container_hash::is_described_class;
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_FALSE((is_described_class<Y1>));
|
||||||
|
BOOST_TEST_TRAIT_FALSE((is_described_class<Y2>));
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
Reference in New Issue
Block a user