Skip to content
Snippets Groups Projects
Unverified Commit 74bc2ce6 authored by René Fritze's avatar René Fritze
Browse files

[type_traits] adds get_template_basename to get name before the arg list

parent 0350f11d
No related branches found
No related tags found
No related merge requests found
// This file is part of the dune-xt-common project:
// https://github.com/dune-community/dune-xt-common
// Copyright 2009-2017 dune-xt-common developers and contributors. All rights reserved.
// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
// or GPL-2.0+ (http://opensource.org/licenses/gpl-license)
// with "runtime exception" (http://www.dune-project.org/license.html)
// Authors:
// Rene Milk (2017)
#include <dune/xt/common/test/main.hxx>
#include <iostream>
#include <dune/xt/common/type_traits.hh>
using namespace Dune::XT::Common;
using namespace std;
template <class T>
struct Foo
{
};
GTEST_TEST(TplName, Match)
{
Foo<Foo<int>> foo;
EXPECT_EQ(get_template_basename(foo), "Foo");
}
...@@ -95,6 +95,13 @@ std::string get_typename(const T&) ...@@ -95,6 +95,13 @@ std::string get_typename(const T&)
return Typename<T>::value(); return Typename<T>::value();
} }
template <class T>
std::string get_template_basename(const T&)
{
const auto str = Typename<T>::value();
const auto r = str.find("<");
return str.substr(0, r);
}
template <class T, class Ptr = void> template <class T, class Ptr = void>
struct is_smart_ptr struct is_smart_ptr
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment