0

I have the following codes:

template <typename Service = timer_impl>
class basic_timer
    : public boost::asio::basic_io_object<Service>    // a class derived from boost::asio::basic_io_object
{

public:

    explicit basic_timer(boost::asio::io_service &io_service)    //boost::asio::io_service::service
        : boost::asio::basic_io_object<Service>(io_service)
    {
    }

    sdgvdg;

    void wait(std::size_t seconds)
    {
        return this->service.wait(this->implementation, seconds);
    }
}

However, VS2013 does not complain this sdgvdg as a compilation error but actually interprets it as basic_timer<Service>::sdgvdg.

Just wants to understand what's going on behind this. Why the compiler won't complain it as an syntax error.

timer_impl is just another class we have.

Praetorian
  • 106,671
  • 19
  • 240
  • 328
user2984297
  • 353
  • 1
  • 3
  • 14
  • Does VS2013 complain if you reference `sdgvdg` anywhere in your code? This probably has to do with MSVC not implementing two phase name lookup for templates, there are a few other answers covering that. – Praetorian Feb 20 '15 at 01:02
  • It actually reports error for me (using VS2013 as well). `error C4430: missing type specifier - int assumed.` – Sergey Krusch Feb 20 '15 at 02:20
  • VS2013 [doesn't support](https://public-dm2306.files.1drv.com/y2pcVF-qTH-2NSnyyjayRN6LDj1SNxsbGRtE3XHc77U1K0-njPWgXVLHeP_1VbQG-bfraWJQ-eZaOluPdO67ocorTjXKBhH8KVo5vgadCemYa4/image1.png?psid=1&rdrts=99039541) [_two-phase lookup_](http://stackoverflow.com/questions/7767626/two-phase-lookup-explanation-needed) so you can usually write whatever you want inside a template if you don't instantiate it. – Constructor Feb 20 '15 at 06:59
  • Actually it is not. I can type in some random names into some other method, but within the same cpp file, and VS won't recognize it as a an error. @Praetorian – user2984297 Feb 20 '15 at 16:23
  • Oh that's interesting. I have double checked it this morning and it still works fine on my vs2013 @SergeyKrusch – user2984297 Feb 20 '15 at 16:24

0 Answers0