Web Wispers 1.2.2 C++ Unit Test Coverage
Current view: top level - ssrc/wispers/utility - emplace.h (source / functions) Hit Total Coverage
Test: Web Wispers 1.2.2 C++ Unit Tests Lines: 7 7 100.0 %
Date: 2012-04-09 Functions: 2 2 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* Copyright 2011 Savarese Software Research Corporation
       2                 :            :  *
       3                 :            :  * Licensed under the Apache License, Version 2.0 (the "License");
       4                 :            :  * you may not use this file except in compliance with the License.
       5                 :            :  * You may obtain a copy of the License at
       6                 :            :  *
       7                 :            :  *     https://www.savarese.com/software/ApacheLicense-2.0
       8                 :            :  *
       9                 :            :  * Unless required by applicable law or agreed to in writing, software
      10                 :            :  * distributed under the License is distributed on an "AS IS" BASIS,
      11                 :            :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12                 :            :  * See the License for the specific language governing permissions and
      13                 :            :  * limitations under the License.
      14                 :            :  */
      15                 :            : 
      16                 :            : /**
      17                 :            :  * @file
      18                 :            :  * This header defines multi-parameter container insertion functions
      19                 :            :  * along the lines of C++0x container_type::emplace().
      20                 :            :  */
      21                 :            : 
      22                 :            : #ifndef __SSRC_WSPR_UTILITY_EMPLACE_H
      23                 :            : #define __SSRC_WSPR_UTILITY_EMPLACE_H
      24                 :            : 
      25                 :            : #include <ssrc/wispers-packages.h>
      26                 :            : 
      27                 :            : #include <utility>
      28                 :            : 
      29                 :            : __BEGIN_NS_SSRC_WSPR_UTILITY
      30                 :            : 
      31                 :            : template<typename container_type, typename P>
      32                 :          1 : inline void emplace(container_type & container, P && p) {
      33                 :          1 :   container.insert(p);
      34                 :          1 : }
      35                 :            : 
      36                 :            : // TODO: Should check to see if container has emplace function and
      37                 :            : // should forward to that if available.
      38                 :            : template<typename container_type, typename T, typename... P>
      39                 :          1 : inline void emplace(container_type & container, T && t, P && ...p) {
      40                 :          1 :   container.insert(t);
      41                 :          1 :   emplace(container, std::forward<P>(p)...);
      42                 :          1 : }
      43                 :            : 
      44                 :            : __END_NS_SSRC_WSPR_UTILITY
      45                 :            : 
      46                 :            : #endif