exceptions.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <felspar/exceptions.hpp>
#include <felspar/memory/exceptions.hpp>

#include <new>


void felspar::memory::detail::throw_bad_alloc(
        char const *m, source_location const &loc) {
    throw stdexcept::bad_alloc{m, loc};
}


void felspar::memory::detail::throw_logic_error(
        char const *m, source_location const &loc) {
    throw stdexcept::logic_error{m, loc};
}


void felspar::memory::detail::throw_length_error(
        char const *m, source_location const &loc) {
    throw stdexcept::length_error{m, loc};
}


void felspar::memory::detail::throw_overaligned_memory(
        std::size_t const alignment, source_location const &loc) {
    throw stdexcept::logic_error{
            "Requested over-aligned memory from the pool of "
                    + std::to_string(alignment) + " bytes",
            loc};
}