You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by al...@apache.org on 2020/07/10 22:38:41 UTC

[incubator-datasketches-cpp] branch tuple_sketch updated: new file

This is an automated email from the ASF dual-hosted git repository.

alsay pushed a commit to branch tuple_sketch
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-cpp.git


The following commit(s) were added to refs/heads/tuple_sketch by this push:
     new e5c1fdf  new file
e5c1fdf is described below

commit e5c1fdf4c0b179a14e2b41445a987dadf21f369d
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Fri Jul 10 15:38:33 2020 -0700

    new file
---
 common/include/conditional_forward.hpp | 40 ++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/common/include/conditional_forward.hpp b/common/include/conditional_forward.hpp
new file mode 100644
index 0000000..e0745ee
--- /dev/null
+++ b/common/include/conditional_forward.hpp
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef CONDITIONAL_FORWARD_HPP_
+#define CONDITIONAL_FORWARD_HPP_
+
+#include <type_traits>
+
+namespace datasketches {
+
+// Forward type T2 as rvalue reference if type T1 is rvalue reference
+
+template<typename T1, typename T2>
+using fwd_type = typename std::conditional<std::is_lvalue_reference<T1>::value,
+    T2, typename std::remove_reference<T2>::type&&>::type;
+
+template<typename T1, typename T2>
+fwd_type<T1, T2> conditional_forward(T2&& value) {
+  return std::forward<fwd_type<T1, T2>>(std::forward<T2>(value));
+}
+
+} /* namespace datasketches */
+
+#endif


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org