Allocator Builder
Policy Based C++ Template Allocator Library
Main Page
Related Pages
Modules
Classes
Files
File List
All
Classes
Functions
Variables
Enumerations
Enumerator
Groups
Pages
memory_corruption_detector.hpp
1
//
3
// Copyright 2014 Felix Petriconi
4
//
5
// License: http://boost.org/LICENSE_1_0.txt, Boost License 1.0
6
//
7
// Authors: http://petriconi.net, Felix Petriconi
8
//
10
11
#pragma once
12
13
#include <cassert>
14
#include <cstdint>
15
#include <iostream>
16
17
namespace
alb {
18
inline
namespace
v_100 {
28
template
<
typename
T,
size_t
Pattern>
29
class
memory_corruption_detector
30
{
31
static_assert(
sizeof
(
char
) <
sizeof
(T) &&
sizeof
(T) <=
sizeof
(uint64_t),
32
"Memory check not for supported types"
);
33
34
T pattern_;
35
36
public
:
37
using
value_type = T;
38
static
const
size_t
pattern = Pattern;
39
40
memory_corruption_detector
() noexcept
41
: pattern_(Pattern)
42
{}
43
44
~
memory_corruption_detector
()
45
{
46
#ifndef NDEBUG
47
if
(pattern_ != Pattern)
48
{
49
std::cout << std::to_string(pattern_) <<
" is unequal to "
<< std::to_string(Pattern) <<
"!"
<< std::endl;
50
throw
42;
51
}
52
#endif
53
assert(pattern_ == Pattern);
54
}
55
};
56
57
template
<
typename
T,
size_t
Pattern>
58
const
size_t
memory_corruption_detector<T, Pattern>::pattern
;
59
}
60
using namespace
v_100;
61
}
alb::v_100::memory_corruption_detector
Definition:
memory_corruption_detector.hpp:29
alb
memory_corruption_detector.hpp
Generated on Sun Nov 15 2015 20:28:19 for Allocator Builder by
1.8.6