Exiv2
enforce.hpp
1 // ***************************************************************** -*- C++ -*-
2 /*
3  * Copyright (C) 2004-2021 Exiv2 authors
4  * This program is part of the Exiv2 distribution.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #include <string>
22 
23 #include "error.hpp"
24 
25 namespace Exiv2::Internal {
33 template <typename exception_t, typename... T>
34 constexpr void enforce(bool condition, T&&... args) {
35  if (!condition) {
36  throw exception_t(std::forward<T>(args)...);
37  }
38 }
39 
44 template <typename... T>
45 constexpr void enforce(bool condition, Exiv2::ErrorCode err_code, T&&... args) {
46  enforce<Exiv2::Error>(condition, err_code, std::forward<T>(args)...);
47 }
48 } // namespace Exiv2::Internal
Helper structure for the Matroska tags lookup table.
Definition: matroskavideo.hpp:39
Error class for exceptions, log message class.
constexpr void enforce(bool condition, T &&...args)
Ensure that condition is true, otherwise throw an exception of the type exception_t.
Definition: enforce.hpp:34
ErrorCode
Complete list of all Exiv2 error codes.
Definition: error.hpp:162