Gabriel B. has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/67652?usp=email )
Change subject: base: Create a gem5 type_traits.hh header
......................................................................
base: Create a gem5 type_traits.hh header
That header currently contains type traits that derive the class, the
return type and the arguments of a member function from a pointer to
that member function.
Change-Id: I41dd41056f507016219d6111d25c8cb4c2ad3439
---
A src/base/type_traits.hh
1 file changed, 108 insertions(+), 0 deletions(-)
diff --git a/src/base/type_traits.hh b/src/base/type_traits.hh
new file mode 100644
index 0000000..bd9db9c
--- /dev/null
+++ b/src/base/type_traits.hh
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2022 Arteris, Inc. and its applicable licensors and
+ * affiliates.
+ * All rights reserved.
+ * This license is licensed under the Gem5 license.
+ *
+ * The license below extends only to copyright in the software and shall
not be
+ * construed as granting a license to any other intellectual property
including
+ * but not limited to intellectual property relating to a hardware
+ * implementation of the functionality of the software licensed
hereunder. You
+ * may use the software subject to the license terms below provided that
you
+ * ensure that this notice is replicated unmodified and in its entirety in
all
+ * distributions of the software, modified or unmodified, in source code
or in
+ * binary form.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __BASE_TYPETRAITS_HH__
+#define __BASE_TYPETRAITS_HH__
+
+#include <tuple>
+#include <type_traits>
+
+namespace gem5
+{
+
+template<typename F>
+struct MemberFunctionSignature;
+template<typename C, typename R, class... A>
+struct MemberFunctionSignature<R(C::*)(A...)>
+{
+ using class_t = C;
+ using return_t = R;
+ using argsTuple_t = std::tuple<A...>;
+};
+template<typename C, typename R, class... A>
+struct MemberFunctionSignature<R(C::*)(A...) const>
+{
+ using class_t = std::add_const_t<C>;
+ using return_t = R;
+ using argsTuple_t = std::tuple<A...>;
+};
+template<typename C, typename R, class... A>
+struct MemberFunctionSignature<R(C::*)(A...) volatile>
+{
+ using class_t = std::add_volatile_t<C>;
+ using return_t = R;
+ using argsTuple_t = std::tuple<A...>;
+};
+template<typename C, typename R, class... A>
+struct MemberFunctionSignature<R(C::*)(A...) const volatile>
+{
+ using class_t = std::add_cv_t<C>;
+ using return_t = R;
+ using argsTuple_t = std::tuple<A...>;
+};
+template<auto F>
+using MemberFunctionClass_t =
+ typename MemberFunctionSignature<decltype(F)>::class_t;
+
+template<auto F>
+using MemberFunctionReturn_t =
+ typename MemberFunctionSignature<decltype(F)>::return_t;
+
+template<auto F>
+using MemberFunctionArgsTuple_t =
+ typename MemberFunctionSignature<decltype(F)>::argsTuple_t;
+
+
+
+} // namespace gem5
+
+#endif // __BASE_TYPETRAITS_HH__
--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/67652?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I41dd41056f507016219d6111d25c8cb4c2ad3439
Gerrit-Change-Number: 67652
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. <gabriel.bus...@arteris.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org