RE: has_trivial_destructor improvable?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> What do you mean "breaks has_trivial_constructor" ?
> Do you just mean has_trivial_default_constructor::value is false?
yes though I'd expect it to be true.

> If you declare the constructor and destructor as defaulted then they will be trivial for placeholder<X> if they are trivial for X:
>        placeholder() = default;
>        ~placeholder () = default;

Doesn't work:

new_placeholder.cpp: In function 'int main()':
new_placeholder.cpp:12:27: error: use of deleted function 'placeholder<T>::placeholder() [with T = std::basic_string<char>]'
new_placeholder.cpp:7:2: error: 'placeholder<T>::placeholder() [with T = std::basic_string<char>]' is implicitly deleted because the default definition would be ill-formed:
new_placeholder.cpp:6:4: error: union member 'placeholder<std::basic_string<char> >::v' with non-trivial 'std::basic_string<_CharT, _Traits, _Alloc>::basic_string() [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]'
new_placeholder.cpp:12:27: error: use of deleted function 'placeholder<T>::~placeholder() [with T = std::basic_string<char>]'
new_placeholder.cpp:8:2: error: 'placeholder<T>::~placeholder() [with T = std::basic_string<char>]' is implicitly deleted because the default definition would be ill-formed:
new_placeholder.cpp:6:4: error: union member 'placeholder<std::basic_string<char> >::v' with non-trivial 'std::basic_string<_CharT, _Traits, _Alloc>::~basic_string() [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]'

    "g++"  -ftemplate-depth-128 -O0 -fno-inline -Wall -g -pthread -m32 -march=core2 -std=c++0x   -I"../../src/libs" -c -o "bin/gcc-4.6.0/debug/address-model-32/link-static/threading-multi/new_placeholder.o" "new_placeholder.cpp"

Note that I'm using the class to avoid construction/deconstruction of an object:

	placeholder<std::string> ps;
	std::string s("hi");
	new(&ps.v) std::string(s);

Chris



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux