Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Compiler crashing template

Compiler crashing template

Scheduled Pinned Locked Moved C / C++ / MFC
linuxdockertoolshelpquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Ben Burnett
    wrote on last edited by
    #1

    I've been working on a small utility that needs to read/write Linux style configuration files. I have just started templating the class responsible for holding the file's content and I've run into a small problem. The following is a listing of the template declaration for the class.

    // ...
    template<
    class Element,
    class Traits = std::char_traits<Element>,
    class Allocator = std::allocator<Element>,
    class Container = std::map<std::basic_string<Element, Traits, Allocator>,
    std::basic_string<Element, Traits, Allocator> >

    class basic_configuration {
    // ...
    };
    // ...

    My hope was to allow for the container used for storing the key/value pairs (key=value) to be changeable via a template parameter. Unfortunately, the above code will not compile... it crashes the compiler (VC 6.0, SP5). Any suggestions on how I might go about fixing this? cheers, -B

    B 1 Reply Last reply
    0
    • B Ben Burnett

      I've been working on a small utility that needs to read/write Linux style configuration files. I have just started templating the class responsible for holding the file's content and I've run into a small problem. The following is a listing of the template declaration for the class.

      // ...
      template<
      class Element,
      class Traits = std::char_traits<Element>,
      class Allocator = std::allocator<Element>,
      class Container = std::map<std::basic_string<Element, Traits, Allocator>,
      std::basic_string<Element, Traits, Allocator> >

      class basic_configuration {
      // ...
      };
      // ...

      My hope was to allow for the container used for storing the key/value pairs (key=value) to be changeable via a template parameter. Unfortunately, the above code will not compile... it crashes the compiler (VC 6.0, SP5). Any suggestions on how I might go about fixing this? cheers, -B

      B Offline
      B Offline
      Ben Burnett
      wrote on last edited by
      #2

      Here is how, for anyone who's interested.

      // ...
      template<
      class Element,
      class Traits = std::char_traits<Element>,
      class Allocator = std::allocator<Element>

      struct MyContainer {
      typedef std::basic_string<Element, Traits, Allocator> string_type;
      typedef std::map<string_type, string_type> type;
      };
      // ...
      template<
      class Element,
      class Traits = std::char_traits<Element>,
      class Allocator = std::allocator<Element>,
      class Container = MyContainer::type

      class basic_configuration {
      // ...
      };
      // ...

      cheers, -B

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups