Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
read_write_lock_acc
#include <iostream> #include <algorithm> struct AB { int x = 1; double y = 100.; }; typedef int read_lock; typedef double write_lock; template<typename LockType, typename ABType> class X : public ABType{ public: typedef const ABType& access_type; }; template<typename ABType> class X<write_lock, ABType> : public ABType{ public: typedef ABType& access_type; }; template<typename LockType> struct XY:protected X<LockType, AB>{ template<typename WeightType> std::enable_if_t<std::is_floating_point<WeightType>::value, WeightType> value() const { return (WeightType)X<LockType, AB>::y; } template<typename WeightType> std::enable_if_t<std::is_integral<WeightType>::value, WeightType> value() const { return X<LockType, AB>::x; } typedef typename X<LockType, AB>::access_type access_type; operator access_type(){ return *this; } access_type data(){ return *this; } }; int main(int, char**) { XY<write_lock> xy; std::cout << xy.value<float>() << std::endl << xy.value<short>() << std::endl; AB& ab = xy; //const AB& ab = xy.data(); AB& ab = xy.data(); return 0; }
run
|
edit
|
history
|
help
0
inheritance test
without HLD range Quey can be handled by just using segment tree on the FLATTENED TREE (euler tour)
СПКИ АП КЭП 2
NonparaRuns
Tray
stack
Motsow
no_error
Tower of hanoi
Sort array of 0's and 1's