template-inheritance

Accessing base member functions in class derived from template class [duplicate]

元气小坏坏 提交于 2020-02-02 06:10:33
问题 This question already has answers here : Why do I have to access template base class members through the this pointer? (3 answers) Closed 5 years ago . I am developing a library at my work and I have designed a complicated inheritance that includes template classes and deriving from them. My problem is that a base template class has virtual overloaded operator that takes 2 arguments and returns some value. In base class this operator is implemented and most of derived classes does not

Force template parameter class to inherit from another templated class with partially fulfilled parameters

╄→гoц情女王★ 提交于 2020-01-11 11:56:48
问题 So I have the following two classes: template < class Cost > class Transformation { public: virtual Cost getCost() = 0; }; template < class TransfCl, class Cost > class State { protected: State(){ static_assert( std::is_base_of< Transformation< Cost >, TransfCl >::value, "TransfCl class in State must be derived from Transformation< Cost >" ); } public: virtual void apply( const TransfCl& ) = 0; }; But would like to, instead, be able to drop the Cost template parameter to State , because State

What is the Type This struct is Inheriting From?

情到浓时终转凉″ 提交于 2019-12-23 10:59:09
问题 So this example from: http://en.cppreference.com/w/cpp/utility/variant/visit declares the specialized type: template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; }; template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>; Which is constructed as an r-value here: std::visit(overloaded { [](auto arg) { std::cout << arg << ' '; }, [](double arg) { std::cout << std::fixed << arg << ' '; }, [](const std::string& arg) { std::cout << std::quoted(arg) << ' '; }, }, v); I'm

What is the Type This struct is Inheriting From?

陌路散爱 提交于 2019-12-23 10:58:38
问题 So this example from: http://en.cppreference.com/w/cpp/utility/variant/visit declares the specialized type: template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; }; template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>; Which is constructed as an r-value here: std::visit(overloaded { [](auto arg) { std::cout << arg << ' '; }, [](double arg) { std::cout << std::fixed << arg << ' '; }, [](const std::string& arg) { std::cout << std::quoted(arg) << ' '; }, }, v); I'm

Django Template inheritance causes a bus error

筅森魡賤 提交于 2019-12-11 01:55:50
问题 I'm working in a multisite hierarchy in a Django template, whereby I need a master base template ( base/base.html ), for which I have several master templates extending from, such as base/base_twocol.html . And then I have templates that extend from those templates, such as base/base_twocol_SECTION . Then I need to have the same set of templates, which will deal with another site, but extending from those templates, such as another_site/base.html , another_site/base_twocol.html , another_site

Issues using Russian Doll Caching with Template Inheritance

◇◆丶佛笑我妖孽 提交于 2019-12-06 08:15:48
问题 I have been using both Template Inheritance and Russian Doll Caching (using the cache_digests gem) independently of one another in select portions of a fairly complex Rails application, with much success. I am having difficulty using the two technologies together, in a sane way, which makes me suspect that I may be doing something wrong... For an extremely simple example, consider an application consisting of two controllers, ThingOnes and ThingTwos. This application has one layout ( layouts

Accessing base member functions in class derived from template class [duplicate]

倾然丶 夕夏残阳落幕 提交于 2019-12-05 22:05:09
This question already has answers here : Why do I have to access template base class members through the this pointer? (3 answers) Closed 5 years ago . I am developing a library at my work and I have designed a complicated inheritance that includes template classes and deriving from them. My problem is that a base template class has virtual overloaded operator that takes 2 arguments and returns some value. In base class this operator is implemented and most of derived classes does not reimplement this operator. Some other class uses derived classes for some work and make use of their operator

Issues using Russian Doll Caching with Template Inheritance

Deadly 提交于 2019-12-04 14:07:58
I have been using both Template Inheritance and Russian Doll Caching (using the cache_digests gem ) independently of one another in select portions of a fairly complex Rails application, with much success. I am having difficulty using the two technologies together, in a sane way, which makes me suspect that I may be doing something wrong... For an extremely simple example, consider an application consisting of two controllers, ThingOnes and ThingTwos. This application has one layout ( layouts/application.html.erb ) which simply renders a header file with: <%= render 'header' %> . By default,

Force template parameter class to inherit from another templated class with partially fulfilled parameters

泄露秘密 提交于 2019-12-02 04:52:40
So I have the following two classes: template < class Cost > class Transformation { public: virtual Cost getCost() = 0; }; template < class TransfCl, class Cost > class State { protected: State(){ static_assert( std::is_base_of< Transformation< Cost >, TransfCl >::value, "TransfCl class in State must be derived from Transformation< Cost >" ); } public: virtual void apply( const TransfCl& ) = 0; }; But would like to, instead, be able to drop the Cost template parameter to State , because State 's functionality is completely independent of Cost . This way, I could create non-abstract classes