1 /* 2 * Copyright 2014 Google Inc. All rights reserved. 3 * 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 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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. 15 */ 16 17 #ifndef FRUIT_COMPONENT_INSTALL_ARG_CHECKS_DEFN_H 18 #define FRUIT_COMPONENT_INSTALL_ARG_CHECKS_DEFN_H 19 20 #include <fruit/impl/component_install_arg_checks.h> 21 22 #include <utility> 23 #include <functional> 24 25 namespace fruit { 26 namespace impl { 27 28 template <typename T> checkAcceptableComponentInstallArg()29FRUIT_ALWAYS_INLINE inline int checkAcceptableComponentInstallArg() { 30 // This lambda checks that the required operations on T exist. 31 // Note that the lambda is never actually executed. 32 auto checkRequirements = [](const T& constRef, T value) { 33 T x1(constRef); 34 T x2(std::move(value)); 35 x1 = constRef; 36 x2 = std::move(value); 37 bool b = (constRef == constRef); 38 std::size_t h = std::hash<T>()(constRef); 39 (void)x1; 40 (void)x2; 41 (void)b; 42 (void)h; 43 }; 44 (void)checkRequirements; 45 return 0; 46 } 47 48 } // namespace impl 49 } // namespace fruit 50 51 #endif // FRUIT_COMPONENT_INSTALL_ARG_CHECKS_DEFN_H 52