Re: compile or not compile

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

 



Eljay Love-Jensen <eljay@xxxxxxxxx> writes:

> Hi,
> 
>  >hm. So if a type is both POD and UDT, what do you do?
> 
> I didn't know that was possible, in C++.

struct f{};
struct f2{int i;};

template<class T>
struct cmp{bool operator()(T lhs,T rhs){return lhs < rhs;}};

f foo;
f2 foo2;
cmp<int> c;

foo, foo2, and c are all both POD and UDT. It's not just possible;
    it's quite common; any C++ project which relies on 3rd party C
    libraries uses types that are both POD and UDT. Most standard C++
    libraries (including gcc's libstdc++) contain many types that that
    are both POD and UDT. 

For reference, see the middle of 9/4:

#    [...] A POD-struct is an aggregate class that has no non-static
#    data members of type non-POD-struct, non-POD-union (or array of
#    such types) or reference, and has no user-defined copy assignment
#    operator and no user-defined destructor. [...]

and also 8.5.1/1:

#    An aggregate is an array or a class (clause 9) with no
#    user-declared constructors (12.1), no private or protected
#    non-static data members (clause 11), no base classes (clause 10),
#    and no virtual functions (10.3).






[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