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 {
30 struct CompileTimeChecker
32 CompileTimeChecker(...);
36 struct CompileTimeChecker<false> {};
38 #define STATIC_CHECK(expr, msg) \
40 class ERROR_ ## msg {}; \
41 CompileTimeChecker<(expr)!= 0>((ERROR_ ## msg())); \
45 * Define used to inform about errors in compilation time
47 * @param msg - message to be displayed,
48 * msg have to be a valid C++ identifier,
49 * other way reported errors will be meaningless
50 * @param C - instance of object which caused problem
51 * error generated by compiler display type of C
53 #define STATIC_ERROR(msg, C) \
59 } // WrtDeviceApisCommon
61 #endif // WRTDEVICEAPIS_COMMONS_STATIC_ASSERT_H