//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <memory>
// shared_ptr
// Example move-only deleter
#ifndef DELETER_H#define DELETER_H#include<type_traits>#include<cassert>structtest_deleter_base{staticintcount;staticintdealloc_count;};inttest_deleter_base::count=0;inttest_deleter_base::dealloc_count=0;template<classT>classtest_deleter:publictest_deleter_base{intstate_;public:test_deleter():state_(0){++count;}explicittest_deleter(ints):state_(s){++count;}test_deleter(consttest_deleter&d):state_(d.state_){++count;}~test_deleter(){assert(state_>=0);--count;state_=-1;}intstate()const{returnstate_;}voidset_state(inti){state_=i;}voidoperator()(T*p){assert(state_>=0);++dealloc_count;deletep;}};template<classT>voidswap(test_deleter<T>&x,test_deleter<T>&y){test_deleter<T>t(std::move(x));x=std::move(y);y=std::move(t);}#endif