2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file StaticAssert.h
18 * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
19 * @author Grzegorz Krawczyk (g.krawczyk@samsung.com)
23 #ifndef WRTDEVICEAPIS_COMMONS_STATIC_ASSERT_H
24 #define WRTDEVICEAPIS_COMMONS_STATIC_ASSERT_H
26 namespace WrtDeviceApis {
29 struct CompileTimeChecker
31 CompileTimeChecker(...);
35 struct CompileTimeChecker<false> {};
37 #define STATIC_CHECK(expr, msg) \
39 class ERROR_##msg {}; \
40 CompileTimeChecker<(expr) != 0>((ERROR_##msg())); \
44 * Define used to inform about errors in compilation time
46 * @param msg - message to be displayed,
47 * msg have to be a valid C++ identifier,
48 * other way reported errors will be meaningless
49 * @param C - instance of object which caused problem
50 * error generated by compiler display type of C
52 #define STATIC_ERROR(msg, C) \
57 } // WrtDeviceApisCommon
59 #endif // WRTDEVICEAPIS_COMMONS_STATIC_ASSERT_H