Manifold
1.0
Robust computational geometry
Loading...
Searching...
No Matches
optional_assert.h
1
// Copyright 2022 The Manifold Authors.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#pragma once
16
17
#ifdef MANIFOLD_EXCEPTIONS
18
#include <stdexcept>
19
#endif
20
21
#ifdef MANIFOLD_DEBUG
22
#include <iostream>
23
#include <sstream>
24
#include <string>
25
26
template
<
typename
Ex>
27
void
Assert(
bool
condition,
const
char
* file,
int
line,
const
std::string& cond,
28
const
std::string& msg) {
29
if
(!condition) {
30
std::ostringstream output;
31
output <<
"Error in file: "
<< file <<
" ("
<< line <<
"): \'"
<< cond
32
<<
"\' is false: "
<< msg;
33
throw
Ex(output.str());
34
}
35
}
36
#define DEBUG_ASSERT(condition, EX, msg) \
37
Assert<EX>(condition, __FILE__, __LINE__, #condition, msg);
38
#else
39
#define DEBUG_ASSERT(condition, EX, msg)
40
#endif
41
42
#ifdef MANIFOLD_EXCEPTIONS
43
#define ASSERT(condition, EX) \
44
if (!(condition)) throw(EX);
45
#else
46
#define ASSERT(condition, EX)
47
#endif
include
manifold
optional_assert.h
Generated by
1.9.8