Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Code Inspection "use template keyword ..."

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
anti-freak Posted - Oct 14 2017 : 05:32:29 AM
Hey there,

here is a bug report about the Code Inspection feature.

Info:
VA_X.dll file version 10.9.2237.0 built 2017.10.03
DevEnv.exe version 15.0.27004.2002 Community (Visual Studio 2017 English)
Programming Language: c++17




It should not be triggered here (the other snippet is almost the same; again std::forward):


8   L A T E S T    R E P L I E S    (Newest First)
anti-freak Posted - Dec 22 2017 : 1:46:27 PM
thanks ;)
sean Posted - Dec 18 2017 : 7:25:19 PM
case=111869 is fixed in build 2248 -- the Code Inspection is no longer flagged, as it is not currently supported.
feline Posted - Oct 20 2017 : 5:39:43 PM
I am seeing the same problem here, this code inspection is not right here:

case=111870

also, interestingly, there is no option to turn off this particular code inspection in the VA options dialog:

case=111869
feline Posted - Oct 20 2017 : 10:35:06 AM
I have the code file, thank you for this:

case=111858
anti-freak Posted - Oct 20 2017 : 09:19:02 AM
It happened again, I already send you the file. Perhaps it helps.
If you need a compilable solution (or at least all necessary dependencies), just tell me.

EDIT: Forgot to tell you the Line with the error:




feline Posted - Oct 16 2017 : 3:35:57 PM
Thank you for the more complete code sample, but like you, I am not seeing any suggestions from Code Inspection here. If this is a bug then it may depend on a fairly specific arrangement of the code, which would explain why a small change stopped this happening. If the problem comes back again, would it be possible to get a copy of the file that is producing the wrong suggestion, purely for testing purposes?

I realise this is often not possible, but it's worth asking on the off chance. If this is possible, please submit the files via the form:

http://www.wholetomato.com/support/contact.asp

including this thread ID or URL in the description, so we can match it up.
anti-freak Posted - Oct 14 2017 : 11:50:30 AM
Interesting..;
While I worked on the project, the suggestion is now gone...
I didn't change much in the file itself; just moved parameters around.
I try to force the suggestion again ;)

But, I can provide you a snippet with more details (still minimized):


#include <iostream>
#include <string>
#include <functional>

namespace prop {
template <class T>
class _Base
{
private:
    T m_Value;
    std::string m_Name;

protected:
    template <class T1>
    void _setValue(T1&& _value)
    {
        m_Value = std::forward<T1>(_value);
    }

public:
    template <class T1>
    _Base(std::string _name, T1&& _value) :
        m_Value(std::forward<T1>(_value)),
        m_Name(std::move(_name))
    {}
    
    const T& operator *() const
    {
        return m_Value;
    }
};

template <class T>
class Property : public _Base<T>
{
private:
    using super = _Base<T>;
    using Validator = std::function<bool(T)>;
    Validator m_Validator;
    
public:
    template <class T1>
    Property(std::string _name, T1&& _value, Validator _validator = nullptr) :
        super(std::move(_name), std::forward<T1>(_value)),
        m_Validator(_validator)
    {}
    
    Property& operator =(const Property& _other) = default;
    template <class T1>
    Property& operator =(T1&& _value)
    {
        if (!m_Validator || m_Validator(_value))
            super::_setValue(std::forward<T1>(_value));
        return *this;
    }
};
}

int main()
{
    prop::Property<int> p{ "test", 0, [](auto _v){
        if (_v <= 0)
        {
            std::cout << "not allowed\n";
            return false;
        }
        return true;
    }};
    
    p = -1;
    p = 5;
    std::cout << *p;
}
feline Posted - Oct 14 2017 : 10:18:45 AM
Your code sample is to small, to many symbols that are not defined, so I have tried to expand this into a small bit of C++ code that will compile. This has given me the code:

template<class T1>
class FelineTemplateBase
{
	FelineTemplateBase<T1>(T1&& _default, std::string _name)	{ }
};

template<class T1>
class PropertyFelineTest : public FelineTemplateBase<T1>
{
	PropertyFelineTest<T1>(T1&& _default, std::string _name, void *_validator = nullptr) :
		super(std::forward<T1>(_default), std::move(_name))
	{

	}
};

code inspection is not suggesting anything for this code however. Can you please try placing this code into your solution, into a header file, and see if Code Inspection suggests anything for you?

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000