Skip to main content
2 votes
3 answers
130 views

It says that the address of operator must be on an lvalue which I don't think the result of declval is: template <typename T> void test_serialisation(T* t) { constexpr bool can_serialise = ...
Zebrafish's user avatar
  • 16.9k
3 votes
2 answers
104 views

I attempted the following approach using c++ SFINAE and std::declval to find if there exists the proper method in a base class, that can be called from the derived class. The derived class gets the ...
Gemini Em's user avatar
3 votes
1 answer
120 views

I'm trying to use a requires clause, and it only works if used on an actual concrete object passed as an argument to a function, but not one given by declval: struct ImageMipInfo { ImageMipInfo() {...
Zebrafish's user avatar
  • 16.9k
1 vote
0 answers
111 views

I have a scheduler class template that I'd like to use with one of several timer classes. I'd like to use a concept to verify a given timer class has what the scheduler needs. // One of several that ...
mthiffau's user avatar
  • 133
3 votes
1 answer
397 views

I saw the example code for template function max. template <typename T1, typename T2, typename RT = std::decay_t<decltype(true ? std::declval<T1>() ...
myoldgrandpa's user avatar
  • 1,049
-1 votes
1 answer
123 views

I just learn the declval keyword in c++ and I was wondering why in the following code (std::add_rvalue_reference<Foo>::type).constFunc7() x = 3; is not compiling. Isn't it the same thing as ...
roi_saumon's user avatar
1 vote
1 answer
220 views

I'm trying to hammer down the type of a this-capturing lambda using a special generating member function with decltype(auto). However, the compiler resists to determine the lambda's type for the ...
glades's user avatar
  • 5,472
8 votes
1 answer
429 views

Code as below or on godbolt compiles with gcc and MSVC but fails with clang. I couldn't find if/where it is forbidden in the standard. In my opinion it should be supported. So who is correct on this, ...
wanghan02's user avatar
  • 1,339
3 votes
1 answer
845 views

I found this type trait which can be used to check if a certain type T supports operator<<: template<class Class> struct has_ostream_operator_impl { template<class V> static ...
ph_0's user avatar
  • 729
1 vote
1 answer
323 views

I try to check template class T in function do_math() on the possibility of throwing an exception in the copy assignment operator. But the following code throws an error: template<class T> void ...
Tippa Toppa's user avatar
8 votes
1 answer
1k views

I have been trying to understand the implementation of std::reference_wrapper, from here, which is as follows: namespace detail { template <class T> constexpr T& FUN(T& t) noexcept { ...
warrior_monk's user avatar
1 vote
1 answer
1k views

On the cppreference-page for std::declval it says the following: Return value Cannot be called and thus never returns a value. What does this mean? Surely we call it when we use it? struct Foo { int ...
JensB's user avatar
  • 959
2 votes
0 answers
261 views

I'm attempting to assert following protected class constructors may or may not throw as follows: #include <utility> #include <type_traits> class X { protected: X() noexcept(false) { } ...
metablaster's user avatar
  • 2,214
1 vote
0 answers
198 views

The first of these two lines fails to compile, the second compiles in MSVC 2017: // std::cout << sizeof(decltype(++std::declval<int>())) << "\n"; //error. expression ...
TRPh's user avatar
  • 197
6 votes
3 answers
262 views

The standard library utility declval is defined as: template<class T> add_rvalue_reference_t<T> declval() noexcept; To add a rvalue reference here seemed like a good idea, if you think ...
Tobi's user avatar
  • 2,839

15 30 50 per page