GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::has_unique_object_representations(3) C++ Standard Libary std::has_unique_object_representations(3)

std::has_unique_object_representations - std::has_unique_object_representations


Defined in header <type_traits>
template< class T > (since C++17)
struct has_unique_object_representations;


If T is TriviallyCopyable and if any two objects of type T with the same value have
the same object representation, provides the member constant value equal true. For
any other type, value is false.


For the purpose of this trait, two arrays have the same value if their elements have
the same values, two non-union classes have the same value if their direct
subobjects have the same value, and two unions have the same value if they have the
same active member and the value of that member is the same.


It is implementation-defined which scalar types satisfy this trait, but
unsigned
(until C++20) integer types that do not use padding bits are guaranteed to have
unique object representations.


The behavior is undefined if T is an incomplete type other than (possibly
cv-qualified) void or array of unknown bound.


The behavior of a program that adds specializations for
has_unique_object_representations or has_unique_object_representations_v is
undefined.


T - a type to check


Helper variable template


template< class T >
inline constexpr bool has_unique_object_representations_v = (since C++17)
has_unique_object_representations<T>::value;

Inherited from std::integral_constant


value true if T has unique object representations , false otherwise
[static] (public static member constant)


operator bool converts the object to bool, returns value
(public member function)
operator() returns value
(C++14) (public member function)


Type Definition
value_type bool
type std::integral_constant<bool, value>


This trait was introduced to make it possible to determine whether a type can be
correctly hashed by hashing its object representation as a byte array.


Feature-test macro: __cpp_lib_has_unique_object_representations

// Run this code


#include <iostream>
#include <type_traits>


struct foo
{
char c;
float f;
short st;
int i;
};


struct bar
{
int a;
int b;
};


int main()
{
std::cout << std::boolalpha
<< "Does foo have unique object representations? "
<< std::has_unique_object_representations_v<foo> << '\n'
<< "Does bar have unique object representations? "
<< std::has_unique_object_representations_v<bar> << '\n';
}


Does foo have unique object representations? false
Does bar have unique object representations? true


is_standard_layout checks if a type is a standard-layout type
(C++11) (class template)
hash hash function object
(C++11) (class template)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.