Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

(c++11) is_trivially_copy_constructible always false if class has destructor

$
0
0

Hi, when some class (T) has destructor is_trivially_copy_constructible<T>::value is always false.

For example:

//trivially copy constructable class with destructor
class CSomeClass {
public:
	int x;

	//explicitly specify default copy constructor
	CSomeClass(const CSomeClass&) = default;

	//non-default destructor
	~CSomeClass(){
	}
};

//all asserts below are failed
static_assert(is_trivially_copy_constructible<CSomeClass>::value, "not a trivially copy constructable");
static_assert(is_trivially_move_constructible<CSomeClass>::value, "not a trivially move constructable");
static_assert(is_trivially_constructible<CSomeClass, const CSomeClass&>::value,  "not a trivially copy constructable");
static_assert(is_trivially_constructible<CSomeClass, CSomeClass&&>::value, "not a trivially copy constructable");

If we remove destructor, all assertion will pass.

According C++11 specification (in my case I refer to draft n3376), is_trivially_copy_constructible<T> should be true when is_copy_constructible<T> is true and only trivial operations are involved.

So I think is_trivially_copy_constructible should be true in the above example.

I have installed the following compiler: Intel® C++ Composer XE 2015   Package ID : w_ccompxe_2015.0.030, for Microsoft* Visual Studio* 2013.

Btw, with ms vc120 compiler, all asserts are pass.


Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>