Skip to content

Commit

Permalink
Moved is_any_same from Decompose.h to is_any.h
Browse files Browse the repository at this point in the history
  • Loading branch information
gtremper committed Aug 6, 2014
1 parent 230b121 commit 1f5f622
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion autowiring/Bolt.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved.
#pragma once
#include "Decompose.h"
#include "is_any.h"
#include "BoltBase.h"

/// <summary>
Expand Down
19 changes: 0 additions & 19 deletions autowiring/Decompose.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,6 @@
#include TYPE_TRAITS_HEADER
#include <typeinfo>

/// <summary>
/// Extended version of is_same
/// </summary>
/// <remarks>
/// Inherits from true_type if T is the same as any of Us...
/// </remarks>
template<typename T, typename... Us>
struct is_any_same;

template<typename T>
struct is_any_same<T> {
static const bool value = false;
};

template<typename T, typename U, typename... Us>
struct is_any_same<T, U, Us...> {
static const bool value = std::is_same<T, U>::value || is_any_same<T, Us...>::value;
};

/// <summary>
/// Provides some static reflection support for member function pointers
/// </summary>
Expand Down
27 changes: 26 additions & 1 deletion autowiring/is_any.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved.
#pragma once
#include TYPE_TRAITS_HEADER

// Check if any T::value is true
/// <summary>
/// Check if any T::value is true
/// </summary>
/// <remarks>
/// Check is_any<...>::value for result
/// </remarks>
template<typename... T>
struct is_any{
static const bool value = false;
Expand All @@ -11,3 +17,22 @@ template<typename Head, typename... Tail>
struct is_any<Head, Tail...>{
static const bool value = Head::value || is_any<Tail...>::value;
};

/// <summary>
/// Extended version of is_same for any number of types
/// </summary>
/// <remarks>
/// Check is_any_same<...>::value for result
/// </remarks>
template<typename T, typename... Us>
struct is_any_same;

template<typename T>
struct is_any_same<T> {
static const bool value = false;
};

template<typename T, typename U, typename... Us>
struct is_any_same<T, U, Us...> {
static const bool value = std::is_same<T, U>::value || is_any_same<T, Us...>::value;
};

0 comments on commit 1f5f622

Please sign in to comment.