File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// This file is a part of the IncludeOS unikernel - www.includeos.org
22//
3- // Copyright 2015 Oslo and Akershus University College of Applied Sciences
3+ // Copyright 2015-2017 Oslo and Akershus University College of Applied Sciences
44// and Alfred Bratterud
55//
66// Licensed under the Apache License, Version 2.0 (the "License");
1919#define NET_UTIL_HPP
2020
2121#include < cstdint>
22+ #include < type_traits>
2223
2324namespace net {
2425
@@ -28,8 +29,12 @@ namespace net {
2829 * e.g., getbits(x, 31, 8) -- highest byte
2930 * getbits(x, 7, 8) -- lowest byte
3031 */
31- template <typename T>
32- constexpr inline auto getbits (T&& x, T&& p, T&& n) noexcept {
32+ template
33+ <
34+ typename T,
35+ typename = std::enable_if_t <std::is_integral<T>::value>
36+ >
37+ constexpr inline auto getbits (const T x, const T p, const T n) noexcept {
3338 return (x >> ((p + 1 ) - n)) & ~(~0 << n);
3439 }
3540
You can’t perform that action at this time.
0 commit comments