LeechCraft  0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
cpufeatures.h
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #pragma once
10 
11 #include <cstdint>
12 #include <utility>
13 #include "sysconfig.h"
14 
15 class QString;
16 
17 namespace LC::Util
18 {
20  {
21  uint32_t Ecx1_ = 0;
22  uint32_t Ebx7_ = 0;
23  public:
24  CpuFeatures ();
25 
26  enum class Feature
27  {
28  SSSE3,
29  SSE41,
30  AVX,
31  XSave,
32  AVX2,
33 
34  None
35  };
36 
37  bool HasFeature (Feature) const;
38 
39  static QString GetFeatureName (Feature);
40 
41  template<typename T>
42  static T Choose (std::initializer_list<std::pair<Feature, T>> funcs, T fallback)
43  {
44  const CpuFeatures features;
45  for (const auto& pair : funcs)
46  if (features.HasFeature (pair.first))
47  return pair.second;
48 
49  return fallback;
50  }
51  private:
52  void DumpDetectedFeatures () const;
53  };
54 }
bool HasFeature(Feature) const
Definition: cpufeatures.cpp:72
No type (item doesn&#39;t correspond to a radio station).
#define UTIL_SYS_API
Definition: sysconfig.h:16
static T Choose(std::initializer_list< std::pair< Feature, T >> funcs, T fallback)
Definition: cpufeatures.h:42