+namespace
+{
+
+template<int L, int U>
+class Rvalue_bit_select_impl
+{
+public:
+ static uint64_t
+ calc(uint64_t x)
+ {
+ return (x & ((1ULL << (U+1)) - 1)) >> L;
+ }
+};
+
+template<int L>
+class Rvalue_bit_select_impl<L, 63>
+{
+public:
+ static uint64_t
+ calc(uint64_t x)
+ {
+ return x >> L;
+ }
+};
+
+// By our convention, L=U=0 means that the whole value should be retrieved.
+template<>
+class Rvalue_bit_select_impl<0, 0>
+{
+public:
+ static uint64_t
+ calc(uint64_t x)
+ {
+ return x;
+ }
+};
+
+} // End anonymous namespace.
+