Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » Make THISFN simpler and more powerful (by taking advantage of some new c++ feature)
Re: Make THISFN simpler and more powerful [message #59158 is a reply to message #59157] |
Fri, 11 November 2022 02:50   |
Lance
Messages: 656 Registered: March 2007
|
Contributor |
|
|
Problem solved with a hackish modification to the definition of the Moveable template in <Core/Topt.h>
template <class T, class B = EmptyClass>
struct Moveable : public B {
typedef B MoveableBase; // Add this line
friend void AssertMoveable0(T *) {}
};
Now it works like a charm 
#include <Core/Core.h>
#include <concepts>
#include <type_traits>
template <class T>
concept UppMoveable = std::is_trivial_v<T> || requires{
typename T::MoveableBase;
requires std::derived_from<T,
Upp::Moveable<T, typename T::MoveableBase>
>;
};
CONSOLE_APP_MAIN
{
using namespace Upp;
struct D{
D(){}
};
struct F{
F() = default;
};
struct E : Moveable<E, D>{
E(){}
};
DUMP(UppMoveable<String>);//true
DUMP(UppMoveable<D>);//false
DUMP(UppMoveable<F>);//true, note the difference between D and F
DUMP(UppMoveable<E>);//true
DUMP(UppMoveable<int64>);//true
}
This is a hack. I am still interested to know if there is a way to do it without resorting to touch <Core/Topt.h>.
[Updated on: Fri, 11 November 2022 02:59] Report message to a moderator
|
|
|
 |
 |
Make THISFN simpler and more powerful
By: Lance on Tue, 18 October 2022 21:08
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Thu, 10 November 2022 00:32
|
 |
|
Re: Make THISFN simpler and more powerful
By: Oblivion on Thu, 10 November 2022 06:29
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Thu, 10 November 2022 12:52
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Thu, 10 November 2022 21:41
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Fri, 11 November 2022 02:50
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Tue, 08 October 2024 18:38
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Tue, 08 October 2024 18:42
|
 |
|
Re: Make THISFN simpler and more powerful
By: Didier on Tue, 08 October 2024 19:25
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Tue, 08 October 2024 20:01
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Wed, 09 October 2024 05:59
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Wed, 09 October 2024 16:09
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Wed, 09 October 2024 16:17
|
 |
|
Re: Make THISFN simpler and more powerful
By: Didier on Wed, 09 October 2024 19:32
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Thu, 10 October 2024 14:01
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Thu, 10 October 2024 14:06
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Tue, 05 November 2024 02:25
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Tue, 05 November 2024 02:33
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Thu, 07 November 2024 00:49
|
 |
|
Re: Make THISFN simpler and more powerful
By: Lance on Fri, 29 November 2024 02:30
|
Goto Forum:
Current Time: Tue Jul 08 23:37:11 CEST 2025
Total time taken to generate the page: 0.03957 seconds
|