std::uses_allocator
std::uses_allocator (std::priority_queue 특수화)
std::uses_allocator 형질을 std::priority_queue에 대해 투명하게 특수화한 구조체예요. 기본 컨테이너가 할당자를 사용할 때(그리고 그때만) 컨테이너 어댑터도 할당자를 사용해요. C++11부터 있어요.
출처: cppreference
본문
<queue> 헤더에 정의돼 있고, std::uses_allocator의 특수화예요.
template< class T, class Container, class Compare, class Alloc >
struct uses_allocator<std::priority_queue<T, Compare, Container>, Alloc>
: std::uses_allocator<Container, Alloc>::type {};
std::priority_queue에 대한 std::uses_allocator 형질의 투명한 특수화를 제공해요. 기본 컨테이너가 할당자를 사용할 때(그리고 그때만) 컨테이너 어댑터도 할당자를 사용해요.
std::integral_constant에서 상속된 멤버들:
- 멤버 상수
value[static]:true(기본 컨테이너가Alloc을 사용할 때). - 멤버 함수
operator bool: 객체를bool로 변환해value를 돌려줘요. - 멤버 함수
operator()(C++14):value를 돌려줘요. - 멤버 타입
value_type=bool,type=std::integral_constant<bool, value>.
예제를 보면요.
#include <memory>
#include <queue>
static_assert(
std::uses_allocator<std::priority_queue<int>, void>::value == false &&
std::uses_allocator<std::priority_queue<int>, std::allocator<int>>::value == true
);
int main() {}
기본 컨테이너(Container)가 Alloc 할당자를 사용하는지에 따라 priority_queue가 할당자 인식을 지원하는지를 알려줘요. scoped allocator 모델에서 할당자 전파에 쓰이는 형질이에요.