00001 /* ///////////////////////////////////////////////////////////////////////// 00002 * File: stlsoft/shims/logical/is_empty/std/container.hpp 00003 * 00004 * Purpose: Generic adapted case of is_empty shim for standard(-like) 00005 * collections. 00006 * 00007 * Created: 18th December 2006 00008 * Updated: 10th August 2009 00009 * 00010 * Home: http://stlsoft.org/ 00011 * 00012 * Copyright (c) 2006-2009, Matthew Wilson and Synesis Software 00013 * All rights reserved. 00014 * 00015 * Redistribution and use in source and binary forms, with or without 00016 * modification, are permitted provided that the following conditions are met: 00017 * 00018 * - Redistributions of source code must retain the above copyright notice, this 00019 * list of conditions and the following disclaimer. 00020 * - Redistributions in binary form must reproduce the above copyright notice, 00021 * this list of conditions and the following disclaimer in the documentation 00022 * and/or other materials provided with the distribution. 00023 * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of 00024 * any contributors may be used to endorse or promote products derived from 00025 * this software without specific prior written permission. 00026 * 00027 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00028 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00029 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00030 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00031 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00032 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00033 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00034 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00035 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00036 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00037 * POSSIBILITY OF SUCH DAMAGE. 00038 * 00039 * ////////////////////////////////////////////////////////////////////// */ 00040 00041 00049 #ifndef STLSOFT_INCL_STLSOFT_SHIMS_LOGICAL_IS_EMPTY_STD_HPP_CONTAINER 00050 #define STLSOFT_INCL_STLSOFT_SHIMS_LOGICAL_IS_EMPTY_STD_HPP_CONTAINER 00051 00052 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION 00053 # define STLSOFT_VER_STLSOFT_SHIMS_LOGICAL_IS_EMPTY_STD_HPP_CONTAINER_MAJOR 2 00054 # define STLSOFT_VER_STLSOFT_SHIMS_LOGICAL_IS_EMPTY_STD_HPP_CONTAINER_MINOR 0 00055 # define STLSOFT_VER_STLSOFT_SHIMS_LOGICAL_IS_EMPTY_STD_HPP_CONTAINER_REVISION 3 00056 # define STLSOFT_VER_STLSOFT_SHIMS_LOGICAL_IS_EMPTY_STD_HPP_CONTAINER_EDIT 21 00057 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ 00058 00059 /* ///////////////////////////////////////////////////////////////////////// 00060 * Includes 00061 */ 00062 00063 #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT 00064 # include <stlsoft/stlsoft.h> 00065 #endif /* !STLSOFT_INCL_STLSOFT_H_STLSOFT */ 00066 #ifndef STLSOFT_INCL_STLSOFT_SHIMS_LOGICAL_IS_EMPTY_UTIL_HPP_FEATURES 00067 # include <stlsoft/shims/logical/is_empty/util/features.hpp> 00068 #endif /* !STLSOFT_INCL_STLSOFT_SHIMS_LOGICAL_IS_EMPTY_UTIL_HPP_FEATURES */ 00069 00070 #ifdef STLSOFT_UNITTEST 00071 # include <deque> 00072 # include <list> 00073 # include <vector> 00074 #endif /* STLSOFT_UNITTEST */ 00075 00076 /* ///////////////////////////////////////////////////////////////////////// 00077 * Namespace 00078 */ 00079 00080 #ifndef _STLSOFT_NO_NAMESPACE 00081 namespace stlsoft 00082 { 00083 #endif /* !_STLSOFT_NO_NAMESPACE */ 00084 00085 /* ///////////////////////////////////////////////////////////////////////// 00086 * Shims 00087 */ 00088 00089 #ifdef STLSOFT_SHIM_LOGICAL_IS_EMPTY_NEEDS_HELP 00090 00091 STLSOFT_OPEN_WORKER_NS_(is_empty_ns) 00092 00093 // This overload of is_empty_helper_assistant() denotes the 00094 // assumption that, by default, a type is able to indicate its 00095 // emptiness by a non-mutating method empty(). 00096 yes_type is_empty_helper_assistant(...) 00097 { 00098 return yes_type(); 00099 } 00100 00101 template <ss_typename_param_k C> 00102 inline ss_bool_t is_empty_helper(C const& c, yes_type) 00103 { 00104 return c.empty(); 00105 } 00106 00107 STLSOFT_CLOSE_WORKER_NS_(is_empty_ns) 00108 00109 #endif /* STLSOFT_SHIM_LOGICAL_IS_EMPTY_NEEDS_HELP */ 00110 00116 template <ss_typename_param_k C> 00117 inline ss_bool_t is_empty(C const& c) 00118 { 00119 #ifdef STLSOFT_SHIM_LOGICAL_IS_EMPTY_NEEDS_HELP 00120 00121 return STLSOFT_WORKER_NS_QUAL_(is_empty_ns, is_empty_helper)(c, STLSOFT_WORKER_NS_QUAL_(is_empty_ns, is_empty_helper_assistant)(&c, &c)); 00122 00123 #else /* ? STLSOFT_SHIM_LOGICAL_IS_EMPTY_NEEDS_HELP */ 00124 00125 return c.empty(); 00126 00127 #endif /* STLSOFT_SHIM_LOGICAL_IS_EMPTY_NEEDS_HELP */ 00128 } 00129 00131 // Unit-testing 00132 00133 #ifdef STLSOFT_UNITTEST 00134 # include "./unittest/container_unittest_.h" 00135 #endif /* STLSOFT_UNITTEST */ 00136 00137 /* ////////////////////////////////////////////////////////////////////// */ 00138 00139 #ifndef _STLSOFT_NO_NAMESPACE 00140 } // namespace stlsoft 00141 #endif /* !_STLSOFT_NO_NAMESPACE */ 00142 00143 /* ////////////////////////////////////////////////////////////////////// */ 00144 00145 #endif /* !STLSOFT_INCL_STLSOFT_SHIMS_LOGICAL_IS_EMPTY_STD_HPP_CONTAINER */ 00146 00147 /* ///////////////////////////// end of file //////////////////////////// */