Ejemplo n.º 1
0
Archivo: main.cpp Proyecto: CCJY/coliru
int main() { 
    
     myclass a(0);
     if (a.content) std::cout << "This should not be happening" << std::endl;
     else std::cout << "Vanilla code has a bug" << std::endl; 
   
     /*
     //this one is a compile error
     myclass aa(1);
     if (aa.content) std::cout << "correct ";
     else std::cout << "incorrect ";
     */
     
     //this one should either pass or compile error
     myprotectedclass b(0);
     if (b.content) std::cout << "Solution has no bug, note that compilation error is acceptable as well for this case" << std::endl;
     else std::cout << "This should not be happening" << std::endl;
     
     //this one should either pass or compile error
     myprotectedclass bb(1);
     if (bb.content) std::cout << "correct ";
     else std::cout << "incorrect ";

     std::cout << "Further tests:" << std::endl;
     
     myprotectedclass c(boost::none);
     if (!c.content) std::cout << "correct ";
     else std::cout << "incorrect ";
     

     myprotectedclass d(myint(0));
     if (d.content) std::cout << "correct ";
     else std::cout << "incorrect ";

     myprotectedclass e(myint(1));
     if (e.content) std::cout << "correct ";
     else std::cout << "incorrect ";

     boost::optional<myint> foobar = boost::none;
     myprotectedclass f(foobar);
     if (!f.content) std::cout << "correct ";
     else std::cout << "incorrect ";

     boost::optional<myint> bar = myint(0);
     myprotectedclass g(bar);
     if (g.content) std::cout << "correct ";
     else std::cout << "incorrect ";

     boost::optional<myint> foo = myint(1);
     myprotectedclass h(foo);
     if (h.content) std::cout << "correct ";
     else std::cout << "incorrect ";
     
    

}
Ejemplo n.º 2
0
Archivo: main.cpp Proyecto: CCJY/coliru
int main() { 
    
    /*
     // now this is a compile error
     myclass a(0);
     if (a.content) std::cout << "correct ";
     else std::cout << "incorrect ";
   */
    
    /*
     //this one is a compile error too but that is less surprising
     myclass c(1);
     if (c.content) std::cout << "correct ";
     else std::cout << "incorrect ";
    */
     
     myclass b(boost::none);
     if (!b.content) std::cout << "correct ";
     else std::cout << "incorrect ";
     

     myclass d(myint(0));
     if (d.content) std::cout << "correct ";
     else std::cout << "incorrect ";

     myclass e(myint(1));
     if (e.content) std::cout << "correct ";
     else std::cout << "incorrect ";

     boost::optional<myint> foobar = boost::none;
     myclass h(foobar);
     if (!h.content) std::cout << "correct ";
     else std::cout << "incorrect ";

     boost::optional<myint> bar = myint(0);
     myclass g(bar);
     if (g.content) std::cout << "correct ";
     else std::cout << "incorrect ";

     boost::optional<myint> foo = myint(1);
     myclass f(foo);
     if (f.content) std::cout << "correct ";
     else std::cout << "incorrect ";
     
    

}
Ejemplo n.º 3
0
Archivo: main.cpp Proyecto: CCJY/coliru
int main() { 
     myclass a(0);
     if (a.content) std::cout << "correct ";
     else std::cout << "incorrect ";
     
     myclass b(boost::none);
     if (!b.content) std::cout << "correct ";
     else std::cout << "incorrect ";
     
     myclass c(1);
     if (c.content) std::cout << "correct ";
     else std::cout << "incorrect ";

     myclass d(myint(0));
     if (d.content) std::cout << "correct ";
     else std::cout << "incorrect ";

     myclass e(myint(1));
     if (e.content) std::cout << "correct ";
     else std::cout << "incorrect ";

}
Ejemplo n.º 4
0
int main () {
  mycontainer<int> myint (7);
  mycontainer<char> mychar ('j');
  return 0;
}
Ejemplo n.º 5
0
Archivo: main.cpp Proyecto: CCJY/coliru
boost::optional<myint> myintctor(int arg) {return myint(arg);}
Ejemplo n.º 6
0
Archivo: main.cpp Proyecto: CCJY/coliru
boost::optional<myint> myintctor(const myint& arg) {return myint(arg);}