lifetime_default.inl 1.56 KB
Newer Older
jpbl's avatar
jpbl committed
1
2
/*
 *    Copyright (c) <2002-2004> <Jean-Philippe Barrette-LaPierre>
3
 *
jpbl's avatar
jpbl committed
4
 *    Permission is hereby granted, free of charge, to any person obtaining
5
6
 *    a copy of this software and associated documentation files
 *    (cURLpp), to deal in the Software without restriction,
jpbl's avatar
jpbl committed
7
8
 *    including without limitation the rights to use, copy, modify, merge,
 *    publish, distribute, sublicense, and/or sell copies of the Software,
9
 *    and to permit persons to whom the Software is furnished to do so,
jpbl's avatar
jpbl committed
10
 *    subject to the following conditions:
11
 *
jpbl's avatar
jpbl committed
12
13
 *    The above copyright notice and this permission notice shall be included
 *    in all copies or substantial portions of the Software.
14
 *
jpbl's avatar
jpbl committed
15
16
 *    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 *    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
18
19
 *    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 *    IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 *    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
jpbl's avatar
jpbl committed
20
21
22
23
 *    TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 *    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

24
25
26
27
28
#ifndef __LIFETIME_DEFAULT_INL__
#define __LIFETIME_DEFAULT_INL__

#include <cstdlib>
#include <stdexcept>
jpbl's avatar
jpbl committed
29
30

template< typename T >
31
void
jpbl's avatar
jpbl committed
32
33
34
35
36
37
38
39
40
utilspp::LifetimeDefault< T >::scheduleDestruction( T *, void (*func)() )
{
   std::atexit(func);
}

template< typename T >
void
utilspp::LifetimeDefault< T >::onDeadReference()
{
41
   throw std::logic_error("Dead reference detected");
jpbl's avatar
jpbl committed
42
43
}

44
#endif // __LIFETIME_DEFAULT_INL__